neilenns / node-deepstackai-trigger

Detects motion using Deepstack AI and calls registered triggers based on trigger rules.
MIT License
167 stars 28 forks source link

Error when annotation is enabled #284

Closed r3dsouza closed 4 years ago

r3dsouza commented 4 years ago

Issue I tried enabling annotations, however, I get the following error. Please could you let me know what I can do to make annotations work. Thanks.

Log entries (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'stringToGlyphs' of null at Object.t.measureText (/home/node/app/bundle.js:544:24375) at Object.t.processTextPath (/home/node/app/bundle.js:544:23398) at fillText (/home/node/app/bundle.js:702:199457) at /home/node/app/bundle.js:702:190245 at Array.map () at Object. (/home/node/app/bundle.js:702:190152) at /home/node/app/bundle.js:702:189268 at Object.next (/home/node/app/bundle.js:702:189373) at o (/home/node/app/bundle.js:702:188087) at runMicrotasks () at processTicksAndRejections (internal/process/task_queues.js:97:5) (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 2)

Installation details

Docker Compose deepstackai-trigger: container_name: deepstackai-trigger image: danecreekphotography/node-deepstackai-trigger:latest hostname: deepstackai-trigger networks:

neilenns commented 4 years ago

I thought I already had a closed bug for this but I guess not. This is fixed as part of my work for #260, but hasn't made it out to the latest build yet. I'm glad you hit it though, I thought I was the only one!

Would you mind testing the fix to see if it resolves the issue? Change your docker-compose.yaml to point to danecreekphotography/node-deepstackai-trigger:issue260 instead of danecreekphotography/node-deepstackai-trigger:latest then run docker-compose up. That should fix it.

splatura commented 4 years ago

I came across the same issue. It only appeared once I added the "annotateImage": true, into the telegram configuration (in triggers.json). I was using the danecreekphotography/node-deepstackai-trigger:dev image.

I have tested with danecreekphotography/node-deepstackai-trigger:issue260 and this has worked OK. Images come through to telegram correctly annotated.

trigger_1 | 2020-06-21T16:28:44+10:00 [Annotations] Annotating /aiinput/garagehd.20200621_142306873.jpg trigger_1 | (node:1) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'stringToGlyphs' of null trigger_1 | at Object.t.measureText (/home/node/app/bundle.js:564:24389) trigger_1 | at Object.t.processTextPath (/home/node/app/bundle.js:564:23412) trigger_1 | at fillText (/home/node/app/bundle.js:721:199545) trigger_1 | at /home/node/app/bundle.js:721:190333 trigger_1 | at Array.map () trigger_1 | at Object. (/home/node/app/bundle.js:721:190240) trigger_1 | at /home/node/app/bundle.js:721:189356 trigger_1 | at Object.next (/home/node/app/bundle.js:721:189461) trigger_1 | at o (/home/node/app/bundle.js:721:188175) trigger_1 | at processTicksAndRejections (internal/process/task_queues.js:97:5) trigger_1 | (Use node --trace-warnings ... to show where the warning was created) trigger_1 | (node:1) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)

neilenns commented 4 years ago

This fix is now available in the latest image. Thanks!

r3dsouza commented 4 years ago

Thanks for fixing this. I pulled the latest version and tried it again and it works perfectly!

Note: in case it helps someone, because I am mapping the volume /node-deepstackai-trigger to a folder on the docker host, I received a permission denied error. In order to fix this, I added the line "user: 99:99" to my docker compose file. Please note the first 99 is the UID and the second 99 is the GID. This runs the container with the privileges of this user.

neilenns commented 4 years ago

It was driving me crazy. I'd hit it all the time during development and couldn't figure out why. Finally found a random comment on a random issue about the library from 2018 and gave it a try and... phew!