Skip to content

Cannot read property 'on' of undefined #49

Closed

Description

@luettgau

I'am trying to get admin-ui to work, but I always get this error from the node_module, when inserting:

instrument(io, { auth: false, });

Any ideas to fix this?

[INFO] 17:33:57 ts-node-dev ver. 2.0.0 (using ts-node ver. 10.9.1, typescript ver. 4.7.4) TypeError: Cannot read property 'on' of undefined at registerEngineListeners (/Volumes/Privat/Code/projects/socketio-server/node_modules/@socket.io/admin-ui/dist/index.js:366:15) at instrument (/Volumes/Privat/Code/projects/socketio-server/node_modules/@socket.io/admin-ui/dist/index.js:424:5) at Object.<anonymous> (/Volumes/Privat/Code/projects/socketio-server/src/index.ts:48:11) at Module._compile (internal/modules/cjs/loader.js:1085:14) at Module._compile (/Volumes/Privat/Code/projects/socketio-server/node_modules/source-map-support/source-map-support.js:568:25) at Module.m._compile (/private/var/folders/73/1v90d1r53836q4zfl33hpb400000gp/T/ts-node-dev-hook-5528744062605151.js:69:33) at Module._extensions..js (internal/modules/cjs/loader.js:1114:10) at require.extensions..jsx.require.extensions..js (/private/var/folders/73/1v90d1r53836q4zfl33hpb400000gp/T/ts-node-dev-hook-5528744062605151.js:114:20) at require.extensions.<computed> (/private/var/folders/73/1v90d1r53836q4zfl33hpb400000gp/T/ts-node-dev-hook-5528744062605151.js:71:20) at Object.nodeDevHook [as .ts] (/Volumes/Privat/Code/projects/socketio-server/node_modules/ts-node-dev/lib/hook.js:63:13) [ERROR] 17:33:57 TypeError: Cannot read property 'on' of undefined

Activity

  1. darrachequesne commented on Sep 19, 2022

    @darrachequesne
    Member

    Hi! Have you found a solution?

  2. added
    question
    on Sep 19, 2022
  3. loczek commented on Oct 2, 2022

    @loczek

    I encountered the same issue. The problem was that the socket io server was a standalone server and not a http server.

    This does't work

    const io = new Server({
     cors: {
        origin: ["https://admin.socket.io"],
        credentials: true,
      },
    });
    
    instrument(io, {
      auth: false,
    });
    
    io.listen(5000)

    and this does

    const httpServer = createServer();
    
    const io = new Server(httpServer, {
      cors: {
        origin: ["https://admin.socket.io"],
        credentials: true,
      },
    });
    
    instrument(io, {
      auth: false,
    });
    
    httpServer.listen(5000)
  4. darrachequesne commented on Oct 7, 2022

    @darrachequesne
    Member

    This should be fixed by b21b649, included in release 0.5.1. Thanks!

  5. added
    bug
    and removed
    question
    on Oct 7, 2022
  6. added this to the 0.5.1 milestone on Oct 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions