feathers-swift
feathers-swift copied to clipboard
Problem using Query with latest feathersjs and feathers-swift-socketio
I'm using feathers-swift and feathers-swift-socketio to connect a iOS app to a feathersjs + mongoose service.
I have been able to successfully connect my iOS app to the feathers server, and I am also able to receive real-time events fine.
This all works fine:
manager = SocketManager(socketURL: URL(string: "http://localhost:3030")!, config: [.log(true), .compress])
socketProvider = SocketProvider(manager: manager, timeout: 5)
feathersSocket = Feathers(provider: socketProvider)
clipService = feathersSocket.service(path: "clip")
// Works fine!
clipService.on(event: .created)
.observeValues { entity in
print(entity)
}
However - I am running into an issue when attempting to query a service.
This simple query...
let query = Query()
.limit(25)
clipService.request(.find(query: query)).on(value: { response in
print(response)
}).start()
causes my server to crash:
/Users/username/Developer/scanner-backend/node_modules/@feathersjs/commons/lib/utils.js:3
return name.replace(/^(\/*)|(\/*)$/g, '');
^
TypeError: name.replace is not a function
at stripSlashes (/Users/username/Developer/scanner-backend/node_modules/@feathersjs/commons/lib/utils.js:3:15)
at Function.lookup (/Users/username/Developer/scanner-backend/node_modules/@feathersjs/transport-commons/lib/routing.js:16:36)
at _run (/Users/username/Developer/scanner-backend/node_modules/@feathersjs/transport-commons/lib/socket/utils.js:70:24)
at exports.runMethod (/Users/username/Developer/scanner-backend/node_modules/@feathersjs/transport-commons/lib/socket/utils.js:97:3)
at Socket.socket.on.args (/Users/username/Developer/scanner-backend/node_modules/@feathersjs/transport-commons/lib/socket/index.js:27:11)
at emitTwo (events.js:126:13)
at Socket.emit (events.js:214:7)
at /Users/username/Developer/scanner-backend/node_modules/socket.io/lib/socket.js:513:12
at _combinedTickCallback (internal/process/next_tick.js:131:7)
at process._tickCallback (internal/process/next_tick.js:180:9)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node src/`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/username/.npm/_logs/2018-03-12T06_00_37_104Z-debug.log
I did some debugging server side, and found that in the file feathersjs/transport-commons/lib/routing.js:16 the problem was that, "path" was being passed in as an array rather than a string. This causes stripSlashes() to crash.

I'm not sure why this is happening or how to fix it properly. As a temporary work around I check for an array there, and pull the first element out. This work around prevents the crash, but all the query parameters are discarded.
Please help!
+1
+1
I ended up writing my own application specific client on top of socketio directly
Thanks for the update. I’m hoping I can figure out how to fix the problem, but am running in to some knowledge gaps. Would you be willing to share you app specific client code? It may help me better understand where the problem lies, or point me in the right direction for creating my own client if all else fails. All good if you prefer not to, just looking for options 🙂
@aarontyler I'm planning big updates for FeathersSwift, Ill be addressing this in that update.
Was this ever addressed? I'm seeing the same issue.