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

Throw when run in production #1703

Open
1 task done
kettanaito opened this issue Aug 18, 2023 · 2 comments · May be fixed by #1791
Open
1 task done

Throw when run in production #1703

kettanaito opened this issue Aug 18, 2023 · 2 comments · May be fixed by #1791
Labels
Milestone

Comments

@kettanaito
Copy link
Member

Scope

Adds a new behavior

Compatibility

  • This is a breaking change

Feature description

I propose MSW, both setupWorker and setupServer throw an exception when detected being run in NODE_ENV === 'production'.

Motivation

When MSW gets to a production environment that's a mistake on the developer's end 9 times out of 10. I believe this would be a good default behavior to have to prevent this kind of mistake.

Implementation

Apart from raising an exception, this feature should also introduce an opt-out mechanism for those who explicitly wish to run MSW in production. We must still permit to run MSW anywhere the end user want but they need to explicitly state their intention. I know that a lot of teachers rely on MSW in production to teach their workshops. I want them to keep doing that without hindrance.

worker.start({ dangerouslyRunInProduction: true })
server.listen({ dangerouslyRunInProduction: true })

When the dangerouslyRunInProduction is provided and equals true, suppress the said exception.

@kettanaito
Copy link
Member Author

@kentcdodds hi, 👋 Do you have any considerations I may be not seeing in regard to this feature? How would this impact your and your students' experience, for example?

@kentcdodds
Copy link
Contributor

The opt-out is sufficient for me. This looks great.

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

Successfully merging a pull request may close this issue.

2 participants