SignalK / signalk-server

An implementation of a Signal K central server for boats.
http://signalk.org
Apache License 2.0
305 stars 152 forks source link

app.notify not working #1795

Open preeve9534 opened 6 hours ago

preeve9534 commented 6 hours ago

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 commented 2 hours ago

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

tkurki commented 1 hour ago

The error message is coming from Express routing method.

panaaj commented 1 hour ago

@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 commented 1 minute ago

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.