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

egg-socket.io start error “Cannot convert undefined or null to object” #997

Closed
windrunnercat opened this issue Jun 5, 2017 · 23 comments
Assignees

Comments

@windrunnercat
Copy link

  • Node Version:
  • Egg Version:
  • Plugin Name:
  • Plugin Version:
  • Platform:
  • Mini Showcase Repository:

我按照egg-socket.io项目中README的步骤,用npm并配置了这个插件,但是在npm run dev的时候一直报如下错误:

/root/projects/agent-server/node_modules/_egg@1.3.0@egg/lib/application.js:38
      throw e;
      ^

TypeError: Cannot convert undefined or null to object
    at Namespace.use (/root/projects/agent-server/node_modules/_socket.io@2.0.2@socket.io/lib/namespace.js:103:21)
    at initNsp (/root/projects/agent-server/node_modules/_egg-socket.io@2.0.0@egg-socket.io/lib/io.js:80:9)
    at module.exports.app (/root/projects/agent-server/node_modules/_egg-socket.io@2.0.0@egg-socket.io/lib/io.js:55:5)
    at AppWorkerLoader.loadFile (/root/projects/agent-server/node_modules/_egg-core@3.7.0@egg-core/lib/loader/egg_loader.js:270:34)
    at getLoadUnits.forEach.unit (/root/projects/agent-server/node_modules/_egg-core@3.7.0@egg-core/lib/loader/mixin/custom.js:25:29)
    at Array.forEach (native)
    at AppWorkerLoader.loadCustomApp (/root/projects/agent-server/node_modules/_egg-core@3.7.0@egg-core/lib/loader/mixin/custom.js:25:8)
    at AppWorkerLoader.load (/root/projects/agent-server/node_modules/_egg@1.3.0@egg/lib/loader/app_worker_loader.js:33:10)
    at new Application (/root/projects/agent-server/node_modules/_egg@1.3.0@egg/lib/application.js:34:19)
    at Object.<anonymous> (/root/projects/agent-server/node_modules/_egg-cluster@1.6.2@egg-cluster/lib/app_worker.js:12:13)

这是什么原因呢?
node版本是6.10.2
npm版本3.10.10
egg-socket.io是直接用npm安装的(也用cnpm安装过,一样的错误)

@ChungTak
Copy link

ChungTak commented Jun 5, 2017

1.4.0 也遇到同样的问题, 之前的 egg1.1.0 一直没有问题,升级就悲催了

@windrunnercat
Copy link
Author

我确实也是 egg 1.4.0,egg-socket.io 2.0.0 是不是版本bug?

@ngot
Copy link
Member

ngot commented Jun 5, 2017

我看下是什么原因

@ChungTak
Copy link

ChungTak commented Jun 5, 2017

已经找到问题了~~ egg-socket.io 2.0.0的原因,退回 egg-socket.io 1.2.2就好了,和egg版本 无关

@ngot
Copy link
Member

ngot commented Jun 5, 2017

本地可以复现。初步判断是socket.io自己偷偷改了什么。 看这个ci之前是没问题的 https://travis-ci.org/eggjs/egg-socket.io/jobs/237482472 。我来细看,底下改了什么。

@windrunnercat
Copy link
Author

降级egg-socket.io的确可用,目前就暂时先用降级的版本了

@ngot
Copy link
Member

ngot commented Jun 5, 2017

socketio/socket.io@2b21690 这个改动导致的。

@ngot
Copy link
Member

ngot commented Jun 5, 2017

delete this.server.eio.initialPacket;

然而, this.server.eio 本身是 undefined 囧...这个breakchangelog

@ngot
Copy link
Member

ngot commented Jun 5, 2017

socketio/socket.io#2963

@ngot ngot changed the title 安装egg-socket.io报错“Cannot convert undefined or null to object” egg-socket.io start error “Cannot convert undefined or null to object” Jun 5, 2017
@ngot
Copy link
Member

ngot commented Jun 5, 2017

Hi everyone, I have reported this issue to the socket.io. Plz, follow it.

@xjchenhao
Copy link

遇到同道中人了 我下午刚好在这个问题上折腾了好久!😅

@acodercat
Copy link

解决办法是什么呢,降级吗

@atian25
Copy link
Member

atian25 commented Jun 8, 2017

npm i egg-socket.io@1 --save

@acodercat
Copy link

希望能用上2.0,谢谢

@atian25
Copy link
Member

atian25 commented Jun 8, 2017

@acodercat 关注 socketio/socket.io#2963 的进展

@dead-horse
Copy link
Member

@ngot 先将 egg-socket.io 写死到 socket.io@2.0.1 吧

@acodercat
Copy link

切换到1.2以后就报这个
module.js:487
throw err;
^

Error: Cannot find module 'uws'
at Function.Module._resolveFilename (module.js:485:15)

@acodercat
Copy link

我是吧2.0卸载了再安装的1.2

@atian25
Copy link
Member

atian25 commented Jun 12, 2017

@ngot 先将 egg-socket.io 写死到 socket.io@2.0.1 吧

eggjs/egg-socket.io#17

@ngot
Copy link
Member

ngot commented Jun 12, 2017

egg-socket.io@2.0.1

@ngot
Copy link
Member

ngot commented Jun 12, 2017

已经发布。暂时锁死版本。 socket.io 那边居然这么久没一点动静...也是醉了

@ngot ngot closed this as completed Jun 12, 2017
@atian25
Copy link
Member

atian25 commented Jun 13, 2017

@ngot 官方修复了,可以解锁了。

socketio/socket.io#2969

@ngot
Copy link
Member

ngot commented Jun 13, 2017

我在搞了,马上发

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

No branches or pull requests

7 participants