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

Bypassed requests made to the firebase emulator result in a timeout #636

Closed
rdjpalmer opened this issue Mar 6, 2021 · 9 comments · Fixed by mswjs/interceptors#95
Closed
Assignees
Labels
bug Something isn't working scope:browser Related to MSW running in a browser

Comments

@rdjpalmer
Copy link

rdjpalmer commented Mar 6, 2021

Describe the bug

Bypassed requests made to the firebase emulator result in a timeout.

Environment

  • msw: 0.27.0
  • nodejs: 15.0.1
  • npm: 7.0.3
  • jest: 26.0.1

To Reproduce

See repro case

Expected behavior

Requests made to the firebase emulator should bypass msw entirely, and succeed.

Additional information

I've tried also supplying handlers which should still result in msw being bypassed, per #234 (comment).

Might be that this is tied to #414.

@rdjpalmer rdjpalmer added the bug Something isn't working label Mar 6, 2021
@matt-kinton
Copy link

matt-kinton commented Mar 6, 2021

I'm also seeing the same problem. I got around it temporarily with this which very clean haha.

const realResponseResolve = async (req: any, res: any, ctx: any) =>
    res(ctx.json(await ctx.fetch(req).then((res: Response) => res.json())));

export const testServer = setupServer(
    rest.get('*/*', realResponseResolve),
    rest.post('*/*', realResponseResolve),
    rest.put('*/*', realResponseResolve),
    rest.patch('*/*', realResponseResolve),
    rest.delete('*/*', realResponseResolve),
    rest.options('*/*', realResponseResolve)
);

@marcosvega91
Copy link
Member

Hi @rdjpalmer, we are sorry that you're facing this issue. This is caused by streams used by firestore. I have created a PR with issue #602. A temporary workaround is to comment these lines

sendToClient(client, {
type: 'RESPONSE',
payload: {
requestId,
type: clonedResponse.type,
ok: clonedResponse.ok,
status: clonedResponse.status,
statusText: clonedResponse.statusText,
body: clonedResponse.body === null ? null : await clonedResponse.text(),
headers: serializeHeaders(clonedResponse.headers),
redirected: clonedResponse.redirected,
},
})
}
if you are not using lifecycle-events

@marcosvega91 marcosvega91 added the scope:browser Related to MSW running in a browser label Mar 7, 2021
@matt-kinton
Copy link

@marcosvega91 I don't think this works for setupServer?

@marcosvega91
Copy link
Member

marcosvega91 commented Mar 7, 2021

I didn't see that the issue was for setupServer. I have updated now my PR and it seems fixed for the browser. I'll check on node what is happening

marcosvega91 added a commit to marcosvega91/node-request-interceptor that referenced this issue Mar 8, 2021
As for the mocked request also bypass request should have the readyState set to 4 (DONE) when a response is received

fix: mswjs/msw#636
@marcosvega91
Copy link
Member

I have opened a PR here that should resolve this issue

marcosvega91 added a commit to marcosvega91/node-request-interceptor that referenced this issue Mar 9, 2021
As for the mocked request also bypass request should have the readyState set to 4 (DONE) when a response is received

fix: mswjs/msw#636
kettanaito pushed a commit to marcosvega91/node-request-interceptor that referenced this issue Mar 9, 2021
As for the mocked request also bypass request should have the readyState set to 4 (DONE) when a response is received

fix: mswjs/msw#636
kettanaito pushed a commit to mswjs/interceptors that referenced this issue Mar 9, 2021
As for the mocked request also bypass request should have the readyState set to 4 (DONE) when a response is received

fix: mswjs/msw#636
@marcosvega91
Copy link
Member

It's the case to leave the issue opened until node-request-interceptor is updated in msw?

@kettanaito
Copy link
Member

@marcosvega91, let's leave it closed, update NRI, and then let the users test it out.

@rdjpalmer
Copy link
Author

@marcosvega91 thanks for looking into this so quickly. Much appreciated. I'll test the fix out as soon as I get a chance

@rdjpalmer
Copy link
Author

It's taken me awhile, but I've finally tested the fix. Works a treat, thanks @marcosvega91!

@github-actions github-actions bot locked and limited conversation to collaborators Nov 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working scope:browser Related to MSW running in a browser
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants