Skip to content

MSW is not intercepting in development in nextjs and graphql api #1049

Answered by kettanaito
themashcodee asked this question in Q&A
Discussion options

You must be logged in to vote

Hey, @themashcodee. Thanks for reporting this.

So the query is not intercepted because by the time it happens the worker is not done registering. I've spotted this by debugging the activeClientsIds in the mockServiceWorker.js file:

// Bypass all requests when there are no active clients.
// Prevents the self-unregistered worked from handling requests
// after it's been deleted (still remains active until the next reload).
if (activeClientIds.size === 0) {
return
}

As the condition above states, if there are no clients (tabs where the worker is ready), bypass the request. That's precisely wh…

Replies: 3 comments 14 replies

Comment options

You must be logged in to vote
9 replies
@alstn2468
Comment options

@kettanaito
Comment options

@adeleke5140
Comment options

@alex-way
Comment options

@garyfagan
Comment options

Answer selected by themashcodee
Comment options

You must be logged in to vote
5 replies
@kettanaito
Comment options

@ironforward
Comment options

@kettanaito
Comment options

@kettanaito
Comment options

@allangrds
Comment options

Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
10 participants