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

server.listen() called after server.close() does not mock response #2370

Open
4 tasks done
vishakha94 opened this issue Nov 28, 2024 · 0 comments
Open
4 tasks done

server.listen() called after server.close() does not mock response #2370

vishakha94 opened this issue Nov 28, 2024 · 0 comments
Labels
bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node

Comments

@vishakha94
Copy link

vishakha94 commented Nov 28, 2024

Prerequisites

Environment check

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

Node.js version

v2.6.6

Reproduction repository

vishakha94@b90344e

Reproduction steps

npm run test:node

Current behavior

We have a NextJS app that implements mocking using feature flag. When we switch the flag off for mocking, we call server.close() and if the feature flag is enabled again, serve.listen() is called.
I observed the following:

  1. the first call to server.listen() mocks API properly
  2. The second call to server.listen() after server.close() does not mock API

Our NextJS app setup is complicated, but I was able to reproduce the issue here: https://github.com/vishakha94/msw/tree/repro-server-close

I ran npm run test:node

Expected behavior

Expect for MSW to resume mocking after server.listen() is called after sever.close().

@vishakha94 vishakha94 added bug Something isn't working needs:triage Issues that have not been investigated yet. scope:node Related to MSW running in Node labels Nov 28, 2024
@vishakha94 vishakha94 changed the title serve.listen() called after serve.close() does not mock response server.listen() called after serve.close() does not mock response Nov 28, 2024
@vishakha94 vishakha94 changed the title server.listen() called after serve.close() does not mock response server.listen() called after server.close() does not mock response Dec 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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

1 participant