Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native node.js fetch doesn't abort when an msw server is running #1701

Closed
4 tasks done
n-e opened this issue Aug 18, 2023 · 3 comments
Closed
4 tasks done

Native node.js fetch doesn't abort when an msw server is running #1701

n-e opened this issue Aug 18, 2023 · 3 comments
Assignees
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@n-e
Copy link

n-e commented Aug 18, 2023

Prerequisites

Environment check

  • I'm using the latest msw version
  • I'm using Node.js version 14 or higher

Node.js version

v20.5.0 and v18.17.1

Reproduction repository

https://github.com/n-e/msw-bug-repro

Reproduction steps

Run node index.js in the provided repo

Current behavior

The fetch call returns after 2 seconds.

Expected behavior

The fetch call should fail with a timeout, since :

  • it has { signal: AbortSignal.timeout(1) } as an argument
  • when server.listen() is commented, it fails
@n-e n-e added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Aug 18, 2023
@kettanaito
Copy link
Member

Hi, @n-e. Thanks for reporting this. It's a known issue and we are addressing it in mswjs/interceptors#394 (discussion #1646). We have to forward the custom AbortController to the internal representation of the request to respect user-based abort signals. While this sounds relatively straightforward, there's more to it than it seems. I need to dive deeper into this and make sure we get this fix right.

@Lukas-Kullmann
Copy link

Hey @kettanaito the related mswjs/interceptors PR has been merged for quite some time now, but it still does not work with the current version of msw.
I guess the problem is that the current msw version uses an older version of @mswjs/interceptors (0.17) than the version that this fix was implemented for (0.24). However, the current interceptor version is not compatible with the current version of msw.
Is there a chance that this will be backported to interceptors v0.17?

@kettanaito
Copy link
Member

Hi, @Lukas-Kullmann. Since 2.0, MSW runs the latest version of Interceptors, which includes the fix for this issue. There are no plans to backport this fix to the older versions of Interceptors because it works on a fundamentally different architecture and requires time that I, sadly, don't have at the moment.

Please upgrade to MSW 2.0 and this issue will be gone. We forward request abort events correctly.

@github-actions github-actions bot locked and limited conversation to collaborators Nov 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node
Projects
None yet
Development

No branches or pull requests

3 participants