I have Loopback code that uses the loopback-connector-remote and does this:
Model.findById(function(err, model) {
// my code
});
When I execute this code, I get:
.../node_modules/strong-remoting/lib/rest-adapter.js:134
callback.apply(invocation, args);
^
TypeError: Cannot read property 'apply' of undefined
at .../node_modules/strong-remoting/lib/rest-adapter.js:134:16
at execStack (.../node_modules/strong-remoting/lib/remote-objects.js:488:7)
at RemoteObjects.execHooks (.../node_modules/strong-remoting/lib/remote-objects.js:492:10)
at HttpInvocation.<anonymous> (.../node_modules/strong-remoting/lib/rest-adapter.js:132:15)
at HttpInvocation.transformResponse (.../node_modules/strong-remoting/lib/http-invocation.js:337:12)
at Request._callback (.../node_modules/strong-remoting/lib/http-invocation.js:261:10)
at Request.self.callback (.../node_modules/request/request.js:199:22)
at emitTwo (events.js:100:13)
at Request.emit (events.js:185:7)
at Request.<anonymous> (.../node_modules/request/request.js:1036:10)
Debugging into rest-adapter, it seems the callback variable is either lost or being cleared somehow. In the following screenshots you can see that callback is still valid until the call to invocation.invoke. When that runs, and its callback is executed, the callback variable has become undefined:



I've tried stepping through the code, but its pretty convoluted so I'm not really sure what is happening.
I have Loopback code that uses the
loopback-connector-remoteand does this:When I execute this code, I get:
Debugging into rest-adapter, it seems the
callbackvariable is either lost or being cleared somehow. In the following screenshots you can see thatcallbackis still valid until the call toinvocation.invoke. When that runs, and its callback is executed, thecallbackvariable has becomeundefined:I've tried stepping through the code, but its pretty convoluted so I'm not really sure what is happening.