question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Request stuck in pending state / promise never resolves

See original GitHub issue

Environment

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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:15 (7 by maintainers)

github_iconTop GitHub Comments

2reactions
kettanaitocommented, Oct 29, 2021

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 a PassThrough 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.

1reaction
kettanaitocommented, Nov 12, 2021

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found