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

app.notify not working #1795

Closed
preeve9534 opened this issue Sep 20, 2024 · 7 comments
Closed

app.notify not working #1795

preeve9534 opened this issue Sep 20, 2024 · 7 comments

Comments

@preeve9534
Copy link

Just updated to server version 2.11.0.

I have a plugin which makes a simple call:

app.notify(watchdog.notificationPath, { state: 'alert', message: 'Waiting for interface to become active' }, plugin.id)

(the notification path and plugin id are valid string values).

The call fails with:

error starting plugin: Error: Route.notify() requires a callback function but got a [object Object]
Error: Route.notify() requires a callback function but got a [object Object]
    at Route.<computed> [as notify] (/opt/homebrew/lib/node_modules/signalk-server/node_modules/express/lib/router/route.js:216:15)
    at app.<computed> [as notify] (/opt/homebrew/lib/node_modules/signalk-server/node_modules/express/lib/application.js:499:19)
    at /Users/preeve/.signalk/node_modules/pdjr-skplugin-interfacewatchdog/dist/index.js:145:25
    at Array.forEach (<anonymous>)
    at Object.start (/Users/preeve/.signalk/node_modules/pdjr-skplugin-interfacewatchdog/dist/index.js:142:42)
    at doPluginStart (/opt/homebrew/lib/node_modules/signalk-server/lib/interfaces/plugins.js:305:20)
    at doRegisterPlugin (/opt/homebrew/lib/node_modules/signalk-server/lib/interfaces/plugins.js:459:13)
    at registerPlugin (/opt/homebrew/lib/node_modules/signalk-server/lib/interfaces/plugins.js:258:13)
    at /opt/homebrew/lib/node_modules/signalk-server/lib/interfaces/plugins.js:209:13
    at Array.forEach (<anonymous>)
    at startPlugins (/opt/homebrew/lib/node_modules/signalk-server/lib/interfaces/plugins.js:208:85)
    at Object.start (/opt/homebrew/lib/node_modules/signalk-server/lib/interfaces/plugins.js:46:13)
    at /opt/homebrew/lib/node_modules/signalk-server/lib/index.js:503:50
    at /opt/homebrew/lib/node_modules/signalk-server/node_modules/lodash/lodash.js:4967:15
    at Function.forIn (/opt/homebrew/lib/node_modules/signalk-server/node_modules/lodash/lodash.js:13018:11)
    at startInterfaces (/opt/homebrew/lib/node_modules/signalk-server/lib/index.js:480:22)
@tkurki
Copy link
Member

tkurki commented Sep 20, 2024

@panaaj documentation for app.notify was added in fc9e64d but where is it implemented?

@tkurki
Copy link
Member

tkurki commented Sep 20, 2024

The error message is coming from Express routing method.

@panaaj
Copy link
Member

panaaj commented Sep 20, 2024

@panaaj documentation for app.notify was added in fc9e64d but where is it implemented?

This has somehow snuck through from #1560. I have raised PR #1796 to remove it.

@preeve9534
Copy link
Author

Just raising a (maybe premature) flag here, but the title of #1796 is rather misleading. AFAIK app.notify has been available and working in SK for a long time. Some recent change in the code base has broken it - this isn't just a documentation issue.

@tkurki
Copy link
Member

tkurki commented Sep 20, 2024

app.notify did not ring any bells in my head, then I found the reference in the documentation, but no trace of an implementation.

Just fired off a few tests with 2.5.0 and 2.0.0, they both throw the same error. I think you're mistaken.

@preeve9534
Copy link
Author

@tkurki - yes you are correct - sorry for the confusion.

It seems that at some point in the distant past I created a wrapper for app that implemented the server API elements that were documented but not yet implemented and amongst these was app.notify(). Move forward five years or so and I awrote this wrapper out of use when I was recoding things into Typescript and wondered why my plugin was causing Signal K to throw an error when app.notify() was documented. Wish I had a perfect memory! My bad.

@tkurki
Copy link
Member

tkurki commented Sep 21, 2024

No worries!

@tkurki tkurki closed this as completed Sep 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants