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

Problem using Query with latest feathersjs and feathers-swift-socketio #25

Open
pdupris opened this issue Mar 12, 2018 · 6 comments
Open
Assignees
Labels

Comments

@pdupris
Copy link

pdupris commented Mar 12, 2018

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.

query-swift-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!

@joaovbalmeida
Copy link

+1

1 similar comment
@aarontyler
Copy link

+1

@pdupris
Copy link
Author

pdupris commented Apr 11, 2018

I ended up writing my own application specific client on top of socketio directly

@aarontyler
Copy link

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 🙂

@daffl daffl added the bug label Apr 25, 2018
@thebarndog
Copy link
Member

@aarontyler I'm planning big updates for FeathersSwift, Ill be addressing this in that update.

@irlanco
Copy link

irlanco commented Nov 22, 2019

Was this ever addressed? I'm seeing the same issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants