-
Notifications
You must be signed in to change notification settings - Fork 158
Warn on second new Pretender #165
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
Conversation
c6d088c
to
4c0e93a
Compare
❤️ LGTM! |
@@ -237,6 +237,11 @@ function interceptor(pretender) { | |||
}; | |||
|
|||
FakeRequest.prototype = proto; | |||
|
|||
if (nativeRequest.prototype._passthroughCheck) { | |||
throw new Error('You created a second Pretender instance while there already one running. ' + |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The text here reads a tad odd to me, maybe:
You created a second Pretender instance while there was already one running.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestions?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
He's saying that the "while there already one running" needs a "was" in there.
I'm not 100% familiar with what happens today if you do this. If things continue to work in this scenario we should change this to a warning (or bump majors). |
@rwjblue If you start new instances while a previous one is running, all new xhr requests go to the most recently created instance, which leads to unexpected routing. If you lose track of the first one you started, you can never restore the native XMLHttpRequest object. Happy to bump majors though to avoid breaking. |
👍 to the major bump, makes sense. |
Closing to do a small fixup. |
To get the fix mentioned in: miragejs/ember-cli-mirage#1000 Made in: miragejs/ember-cli-mirage#984 To deal with this change: pretenderjs/pretender#165
Not everyone is diligent about shutting down their Pretenders. This will prevent a second instance from starting up.