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

Bug with the router class #6034

Open
evokerking1 opened this issue Oct 8, 2024 · 5 comments
Open

Bug with the router class #6034

evokerking1 opened this issue Oct 8, 2024 · 5 comments

Comments

@evokerking1
Copy link

evokerking1 commented Oct 8, 2024

This is my code
``// import the route
import { playground } from "@colyseus/playground"
// ...
const monitor = require("@colyseus/monitor").monitor
const express = require("express")
const app = express
const route = app.Router

// ...
route.use("/monitor", monitor)

// bind it as an express middleware
route.use("/playground", playground)

app.listen(3000)

which throws this error

$ bun run index.js
478 | end: false
479 | }, fn);
480 |
481 | layer.route = undefined;
482 |
483 | this.stack.push(layer);
^
TypeError: undefined is not an object (evaluating 'this.stack.push')
at use (/workspace/colyseus-testing-ground/node_modules/express/lib/router/index.js:483:10)
at /workspace/colyseus-testing-ground/index.js:10:7

Bun v1.1.30 (Linux x64)
error: script "test" exited with code 1
and the code that throws this error in the /lib/router/index.js line 483 or this.layer.push()

@evokerking1
Copy link
Author

evokerking1 commented Oct 8, 2024

Whats require-triage label?

@dpopp07
Copy link

dpopp07 commented Oct 9, 2024

@evokerking1 The Triage Process indicates that it means further triaging is needed to properly classify the issue.

@nwalters512
Copy link

You wrote const route = app.Router. Is this what's actually in your code? I'd recommend reviewing the docs, which make it clear that you must call Router. That is:

const router = app.Router()

@evokerking1
Copy link
Author

You wrote const route = app.Router. Is this what's actually in your code? I'd recommend reviewing the docs, which make it clear that you must call Router. That is:

const router = app.Router()

That is all my code.

@IamLizu
Copy link
Member

IamLizu commented Oct 10, 2024

Hey @evokerking1 👋

Like @nwalters512 pointed out, could you please confirm if the issue persists even after changing,

const route = app.Router

to,

const router = app.Router()

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

5 participants