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

FeathersJS Socket.IO and net module #95

Open
soullivaneuh opened this issue Mar 1, 2020 · 3 comments
Open

FeathersJS Socket.IO and net module #95

soullivaneuh opened this issue Mar 1, 2020 · 3 comments

Comments

@soullivaneuh
Copy link

Which platform(s) does your issue occur on?

  • Android v6

Please, provide the following version numbers that your issue occurs with:

  • CLI: 6.4.1
  • Cross-platform modules: 6.2.3
  • Runtime(s): 6.2.0
  • Plugin(s):
    "nativescript-geolocation": "^5.1.0",
    "nativescript-socketio": "^3.3.1",
    "nativescript-tailwind": "^1.2.1",
    "nativescript-theme-core": "~2.0.24",
    "nativescript-ui-calendar": "^6.0.0",
    "@feathersjs/authentication-client": "^4.5.1",
    "@feathersjs/client": "^4.5.1",
    "@feathersjs/socketio-client": "^4.5.1",

Please, tell us how to recreate the issue in as much detail as possible.

Import Feathers socket io client on one of your pages:

import socketio from '@feathersjs/socketio-client';

And run tns build android

You will get this error:

ERROR in ../node_modules/debug/src/node.js
Module not found: Error: Can't resolve 'net' in '/home/sullivan/p/github.com/soullivaneuh/svelte-native-test/node_modules/debug/src'
 @ ../node_modules/debug/src/node.js 193:16-30
 @ ../node_modules/debug/src/index.js
 @ ../node_modules/@feathersjs/transport-commons/lib/client.js
 @ ../node_modules/@feathersjs/transport-commons/client.js
 @ ../node_modules/@feathersjs/socketio-client/lib/index.js
 @ ./App.svelte
 @ ./app.ts
Executing webpack failed with exit code 2.

It's maybe FeathersJS related only, but I'm not sure and would like to know what you, native expert, thing about this issue.

Is there any code involved?

Here is a PR coming from a fresh svelte-native template: https://github.com/soullivaneuh/svelte-native-test/pull/2

@soullivaneuh
Copy link
Author

If I install the net package and run tns run android (not build), now I get:

System.err: TypeError: Cannot read property 'env' of undefined
System.err:     at com.tns.Runtime.runModule(Native Method)
System.err:     at com.tns.Runtime.runModule(Runtime.java:674)
System.err:     at com.tns.Runtime.run(Runtime.java:666)
System.err:     at com.tns.NativeScriptApplication.onCreate(NativeScriptApplication.java:21)
System.err:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1119)
System.err:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5740)
System.err:     ... 8 more

And the error is gone if I remove the import.

I'm not sure I have to install the net module by the way, I don't have to on web dev.

@soullivaneuh
Copy link
Author

I also opened feathersjs/feathers#1843, I'm not very sure what should be fixed here.

@marshallswain
Copy link

marshallswain commented Oct 23, 2020

@soullivaneuh did the suggested fix resolve your issue?

I think it would be something like this:

import feathers from '@feathersjs/client'
import feathersSocketIO from '@feathersjs/socketio-client'

var SocketIO = require('nativescript-socketio').SocketIO;
var socket = new SocketIO('http://localhost:3030', { transports: ['websocket'] })

// let hasConnectedOnce = false
const feathersClient = feathers()
  .configure(feathersSocketIO(socket))

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

2 participants