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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

msw doesn't seem to actually work with this setup #25

Closed
johncantrell97 opened this issue Mar 18, 2022 · 7 comments
Closed

msw doesn't seem to actually work with this setup #25

johncantrell97 opened this issue Mar 18, 2022 · 7 comments

Comments

@johncantrell97
Copy link

johncantrell97 commented Mar 18, 2022

Not sure if I'm doing something wrong but when I run npm run dev I see that the mocks are being started and loaded with this log console.info("馃敹 Mock server running");

However, if I change onUnhandledRequest to "error" like this server.listen({ onUnhandledRequest: "error" }); I never see any errors or logs about unhandled requests even though I'm definitely making requests to Stripe.

I've tried all sorts of things to debug but can't make progress.

Any ideas?

edit: seems like the sanbox is likely starting separate node processes to run the lambdas which MSW won't see.

@kentcdodds
Copy link
Member

Ah, that's a bummer. I tested it in the other stacks but not this one. We may need to be a bit more invasive by requiring the mocks in app code 馃槵

@tbeseda can you confirm that this will run in a different node process from the app? If so, we may need to move that require into app/entry.server.ts during development.

Would be better if there were a way to do a --require sort of thing with arc directly so we don't have to put it in app code.

@johncantrell97
Copy link
Author

Yeah, I'm playing around with running msw in server.ts and it seems to work okay.

@johncantrell97
Copy link
Author

Can confirm it does work if you start the server in app/entry.server.ts but it feels like it really slows every request down quite a bit. Also saw some issues with a 3rd party library that was using axios to post.

@tbeseda
Copy link
Contributor

tbeseda commented Mar 21, 2022

Correct, Architect will run each function execution in a new process. It does use the same environment from the root project/package.json, but doesn't inherit from the parent process. This behavior is important to emulating how Lambda will run the function in isolation on AWS.
Obviously msw is really helpful for mocking APIs that a function would interact with, but I'm not sure how it could be wrapped around a function in Sandbox. A plugin might help, but I think no matter what it has to be started each time a request is made since there are no long running processes.

@eXigentCoder
Copy link

eXigentCoder commented Jun 10, 2022

Is the issue with Architect running functions in a new process also the reason why I can't seem to get VS Code debugging working with the routes in the Grunge Stack?

Used a debugger; statement in a standard remix app and works like a charm, but in Grunge, no joy 馃槀

@gnllucena
Copy link

any luck trying to make debugger work in grunge stack @eXigentCoder?

@pcbl
Copy link

pcbl commented Jul 16, 2023

I am also facing challenges to debug in grunge stack. Anyonbe knows of some advices to make it work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants