Open dhylands opened 6 years ago
Well, this is strange. This is the code that's failing:
...
} else if (plugin) {
plugin.unload();
}
... So how is plugin
undefined when calling unload()
on it?
Hi @mrstegeman and @dhylands,
I just got this error with https://github.com/flatsiedatsie/webthings-network-presence-detection. What's the fix/workaround please?
Thanks 🙂
@madb1lly Do you have a log showing the error? It may be different from this one.
Hi @mrstegeman, Disable add-on:
2020-05-28 07:46:01.361 ERROR : Failed to toggle add-on network-presence-detection-adapter 2020-05-28 07:46:01.459 ERROR : TypeError: Cannot read property 'send' of undefined at Plugin.sendMsg (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:580:1) at Plugin.unload (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:737:1) at AddonManager.unloadAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:963:1) at AddonManager.disableAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:599:1)
Enable add-on:
2020-05-28 07:48:44.393 INFO : Loading add-on: network-presence-detection-adapter 2020-05-28 07:48:44.601 INFO : Unhandled Rejection 2020-05-28 07:48:44.638 ERROR : { Error: spawn ENOMEM at ChildProcess.spawn (internal/child_process.js:366:11) at spawn (child_process.js:551:9) at startPromise.Settings.get.then (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:644:1) errno: 'ENOMEM', code: 'ENOMEM', syscall: 'spawn' }
Removing add-on:
2020-05-28 07:49:18.392 ERROR : Failed to unload network-presence-detection-adapter properly: TypeError: Cannot read property 'send' of undefined
Re-installing add-on:
2020-05-28 07:50:41.349 INFO : Fetching add-on https://s3-us-west-2.amazonaws.com/mozilla-gateway-addons/network-presence-detection-adapter-0.1.2.tgz as /tmp/x74vae/network-presence-detection-adapter.tar.gz 2020-05-28 07:50:45.431 INFO : Expanding add-on /tmp/x74vae/network-presence-detection-adapter.tar.gz 2020-05-28 07:50:48.754 ERROR : Failed to unload network-presence-detection-adapter properly: TypeError: Cannot read property 'send' of undefined 2020-05-28 07:50:55.087 INFO : Loading add-on: network-presence-detection-adapter 2020-05-28 07:50:55.309 INFO : Unhandled Rejection 2020-05-28 07:50:55.341 ERROR : { Error: spawn ENOMEM at ChildProcess.spawn (internal/child_process.js:366:11) at spawn (child_process.js:551:9) at startPromise.Settings.get.then (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:644:1) errno: 'ENOMEM', code: 'ENOMEM', syscall: 'spawn' }
I've tried rebooting and it doesn't have an effect.
Is it the same issue? If yes and you think it's a gateway issue then I'll raise a new issue here.
Cheers 🙂
I'm unable to reproduce, but this seems problematic to me:
2020-05-28 07:48:44.638 ERROR : { Error: spawn ENOMEM
at ChildProcess.spawn (internal/child_process.js:366:11)
at spawn (child_process.js:551:9)
at startPromise.Settings.get.then (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:644:1) errno: 'ENOMEM', code: 'ENOMEM', syscall: 'spawn' }
It seems like there may be a memory leak somewhere (in the adapter?). Is there anything else running on your Pi? Perhaps we're hitting the upper memory bound of your Pi?
No nothing else running, it's for the gateway only. You may be right about memory though, it is only a 512MB Model B and when trying to do these things it had ~50MB free, which is a bit tight. A month or so ago it used to be ~125MB free though and I've not figured out what changed.
You might want to watch top
and try to figure out what’s using so much memory and/or leaking.
You could also try to add a swap file to your RPi, although its performance is going to be pretty terrible on the SD card.
Perhaps this error I'm seeing is related:
2021-02-04 07:41:20.949 ERROR : Failed to restart add-on voco
2021-02-04 07:41:20.988 ERROR : TypeError: Cannot read property 'send' of undefined
at Plugin.sendMsg (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:580:1)
at Plugin.unload (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:737:1)
at AddonManager.unloadAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:979:1)
at ./src/controllers/addons_controller.js.AddonsController.put (/home/pi/mozilla-iot/gateway/build/webpack:/src/controllers/addons_controller.js:111:1)
2021-02-04 07:41:51.130 ERROR : Failed to restart add-on voco
2021-02-04 07:41:51.150 ERROR : TypeError: Cannot read property 'send' of undefined
at Plugin.sendMsg (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:580:1)
at Plugin.unload (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:737:1)
at AddonManager.unloadAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:979:1)
at ./src/controllers/addons_controller.js.AddonsController.put (/home/pi/mozilla-iot/gateway/build/webpack:/src/controllers/addons_controller.js:111:1)
This is on a Pi zero. No messages about being out of memory. And the latest version of Voco should theoretically use less memory, since the hotword detection no longer runs on it, but is taken care of by the central voco server.
Hmm, I do see this ENOMEM a bit further in the log...
2021-02-04 08:23:56.488 ERROR : Failed to toggle add-on voco
2021-02-04 08:23:56.510 ERROR : TypeError: Cannot read property 'send' of undefined
at Plugin.sendMsg (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:580:1)
at Plugin.unload (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:737:1)
at AddonManager.unloadAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:979:1)
at AddonManager.disableAddon (/home/pi/mozilla-iot/gateway/build/webpack:/src/addon-manager.js:615:1)
2021-02-04 08:24:48.343 INFO : Loading add-on: voco
2021-02-04 08:24:48.465 INFO : Unhandled Rejection
2021-02-04 08:24:48.489 ERROR : { Error: spawn ENOMEM
at ChildProcess.spawn (internal/child_process.js:366:11)
at spawn (child_process.js:551:9)
at startPromise.Settings.get.then (/home/pi/mozilla-iot/gateway/build/webpack:/src/plugin/plugin.js:644:1) errno: 'ENOMEM', code: 'ENOMEM', syscall: 'spawn' }
I think I discovered what was causing my issue:
node build/gateway.js
takes 377Mb already, which I assume is the gateway process.pagekyte
is using a lot of what little memory is left on a Raspberry Pi zero. @flatsiedatsie wrote:
pagekyte is using a lot of what little memory is left on a Raspberry Pi zero.
Just a thought, but if the gateway is getting tight on memory on a 512MB RAM device, one place we might be able to reduce memory usage slightly (other than more drastic steps like replacing the base OS!) is by replacing pagekite.py with libpagekite, which is written in C and is intended for embedded applications.
After disabling the thing-url-adapter, it continues to run: