Request stuck in pending state / promise never resolves
See original GitHub issueEnvironment
Name | Version |
---|---|
msw | 0.35.0 |
node | 14.17.6 |
OS | codesandbox & ubuntu 20.04 |
Request handlers
// Example of declaration. Provide your code here.
import { setupServer } from 'msw/node'
import { rest } from 'msw'
const server = setupServer()
server.listen({
onUnhandledRequest: "bypass"
})
stripe.customers.update("customer_id", {
name: "stephan",
email: "stephan@example.com"
}).finally(() => {
// you'll never come here
});
Actual request
stripe.customers.update("customer_id", {
name: "stephan",
email: "stephan@example.com"
}).finally(() => {
// you'll never come here
});
Current behavior
Request is made, Stripe shows that there was a successful response, but the promise never resolves.
Expected behavior
Request should resolve
Screenshots
codesandbox
https://codesandbox.io/s/spring-dawn-3cht3?file=/pages/api/stripe.js
terminal
https://user-images.githubusercontent.com/1196524/137531832-6b5fb6c8-e4f5-4c0d-9a2f-f16f1698f48c.mp4
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:15 (7 by maintainers)
Top Results From Across the Web
Javascript promise stuck in pending state - Stack Overflow
I want to run a loop in order, but I'm using promises, and they're stuck in a "pending" state. function print(i){ return new...
Read more >Promise <pending> - Damaris Göbel
The promise will always log pending as long as its results are not resolved yet. You must call .then on the promise to...
Read more >How to solve the problem of Promise { <pending> }? - JavaScript
Here is my code: Blockquote router.get("test", async ctx => { let q = await ctx.db .execute(`SELECT w.create_time as create_time,w.camera_id ...
Read more >asynchronous function returning promise pending instead of a ...
The problem seems to be that Promise is still Pending so it is skipping the .Then and running the console.Log first after the...
Read more >Why does an Async function return a pending promise ... - Quora
Because the thing you were waiting for hasn't happened yet, so it is still a promise that hasn't resolved. So now you are...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I’ve implemented the fix in https://github.com/mswjs/interceptors/pull/165 but currently experience a regression in one of the tests. Once it’s resolved, the fix will be merged.
It seems I’ve finally found a way to properly clone the
IncomingMessage
by piping it to aPassThrough
stream in order to read its “data” twice: for the internal “response” event and for the arbitrary response event listeners that the request client (or developer) may attach.The fix will propagate with the next update of the
@mswjs/interceptors
library. We’re currently working on a few bug fixes we’d like to include in that next release. I’d expect it to be released this month.