-
Notifications
You must be signed in to change notification settings - Fork 38
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
TypeError unref of undefined when running proper-lockfile inside of react-scripts test #90
Comments
Looking at the code, the error you reported shouldn’t be happening as setTimeout should always return something. In case of the browser, it returns a integer, while in node it returns a time ref. It seems to me that your test environment is somehow mocking setTimeout in a bad way and returning nullish, causing the issue. Are you using any lib to mock timers? |
Thanks for getting back @satazor I've attemped using I was able to confirm that creating a manual mock of It'll take further digging to figure out exactly what |
I'm doing the same, and seeing the same error. The PR that @mboperator submitted (#91) mitigates the issue in my case. Given the fact that it's necessary to be defensive here for cases where The current implementation is defensive against everything that happens to be truthy but doesn't implement |
I understand that the overall issue caused a lot of frustration. If the check was in place, you wouldn’t experience this issue at all, which at first might be a good thing. But if you think about it, it would be hiding a flaw from somewhere else that would eventually bite you in the future. The spec says that setTimeout must return a handle that can be passed to clearTimeout, see https://html.spec.whatwg.org/multipage/timers-and-user-prompts.html#timers Since this is a bug with the environment you are running tests and not this lib, it seems unreasonable to implement a fix/check here. |
Forgive me, I'm pretty new to reading specs like this, but it looks to me like If it really is against the spec to return "The clearTimeout() and clearInterval() methods must clear the entry identified as handle from the list of active timers of the WindowOrWorkerGlobalScope object on which the method was invoked, if any, where handle is the argument passed to the method. (If handle does not identify an entry in the list of active timers of the WindowOrWorkerGlobalScope object on which the method was invoked, the method does nothing.)"
|
Ah just read a little more and I see where it is required to be an integer. "If previous handle was provided, let handle be previous handle; otherwise, let handle be a user-agent-defined integer that is greater than zero that will identify the timeout to be set by this call in the list of active timers." I'm happy to go make this argument with Jest |
This is an old issue i'm going to close this! Feel free to reopen if it needs more discussion. Thank you. |
Background
I'm mounting
ipfs
, which has a dependency onipfs-repo
inside of a react app generated viacreate-react-app
. Running a very basic render test results in the following exception.Problematic Command
$ NODE_PATH=src/ CI=true react-scripts test && yarn run lint
Exception
Potential Solution
Modifying
lockfile.js:180
to check for the existence oflock.updateTimeout
first solves the runtime error. Would love to discuss whether that's the right way to go about it.The text was updated successfully, but these errors were encountered: