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

Uncaught TypeError: this.timer.unref is not a function #31

Open
xavier-breuil opened this issue Dec 4, 2018 · 7 comments
Open

Uncaught TypeError: this.timer.unref is not a function #31

xavier-breuil opened this issue Dec 4, 2018 · 7 comments
Labels

Comments

@xavier-breuil
Copy link

Hello,

I have some issue feeding the dog.
I just paste the example given and get the following error then after one seconds the dog goes to sleep (we can see the log in the console):

Uncaught TypeError: this.timer.unref is not a function
at Watchdog.startTimer (watchdog.js:102)
at Watchdog.feed (watchdog.js:194)
at Module../src/hello_world/hello_world.js (hello_world.js:19)
at webpack_require (bootstrap:19)
at Module../src/app.js (app.js:1)
at webpack_require (bootstrap:19)
at ./config/env_development.json.module.exports.name (bootstrap:83)
at bootstrap:83

I just started a project with electron. Basically I cloned the electron boilerplate (https://github.com/szwacz/electron-boilerplate), install watchdog, copy and paste the example of this repos and launched it.

My configuration is:

  • node: 9.11.1
  • electron: 1.7.9

Do you have any idea where this may come from?

Thank you

@huan
Copy link
Owner

huan commented Dec 4, 2018

It should work because the CI is passing.

You might run into this issue jestjs/jest#1909 and please check your environment in a pure node like this: discordjs/RPC#22

@xavier-breuil
Copy link
Author

Ok. Thank you for your advice. It of course works in pure node, but I reckon somehow the setTimeout function in the scope of my app is not the native one (since it doesn't have the unref method). So far I couldn't find a way to force it.
I guess I'll either clone your project and force setTimeout to the native node implementation inside of your code or use a homemade solution to fulfill my needs.

@thiago-sylvain
Copy link

I confirm I have the same problem than @xavier-breuil.
Node: 9.11.2
Electron: 1.7.9
Watchdog: 0.8.17

@huan huan added the question label Dec 6, 2018
@huan huan changed the title Error when feeding the dog Uncaught TypeError: this.timer.unref is not a function Dec 6, 2018
@davelnewton
Copy link

This is also an issue when running under Electron/React when the watchdog timer(s) are in an imported library.

@huan
Copy link
Owner

huan commented Mar 25, 2019

@davelnewton thanks for report that.

Could you please provide a minimum runnable code to show your problem?

I'd like to fix this if I can understand the situation we are facing to.

@davelnewton
Copy link

Could you please provide a minimum runnable code to show your problem?

Not trivially, but I was using it in a module that was included in an Electron (via electron-forge) project. The solution is as @xavier-breuil states: it's using the standard browser-ish timers which do not have the unref() function.

I removed the library and did essentially the same thing as the library using the NodeJS timers module. For the library to work across environments it'd need to do a browser-ish check, or if it's intended to be used only in a NodeJS environment it'd need to use the timers module from NodeJS.

@huan
Copy link
Owner

huan commented Sep 8, 2021

Should be fixed with watchdog@0.8.21 and above.

Thank you very much for the reporting!

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

No branches or pull requests

4 participants