Skip to content

[Bug] something went wrong when use Router in expressjs with skywalking #9165

@Midqiu

Description

@Midqiu

Search before asking

  • I had searched in the issues and found no similar issues.

Apache SkyWalking Component

NodeJS Server Side Agent (apache/skywalking-nodejs)

What happened

when i user router in expressjs with skywalking, some went wrong.

app.use("/hello/",async function (req, res) {
  res.send("Hello")
})

// this is router
const router = express.Router()
router.get("/router/", async function (req, res) {
  res.send("Hello router")
})

app.use(router)


app.use("/hello2/", async function (req, res) {
  res.send("Hello2");
});

and the result is:
this is OK:
)(G$S26HXV8(Q$PFMR82R`B

but this has two records in skywalking:
MTL`BUD38((@L5J5EF2%(OE

and this has two records and tell me has error:
SW9_4ZP%`AC9L1EYD%SL(@4

What you expected to happen

/router/ and /hello2/aaa has one record and has no error。

How to reproduce

1. start this server:


var express = require('express')
var agent = require('skywalking-backend-js').default

agent.start({
    serviceName: "***",
    collectorAddress: "***",
})
const app = express()

app.use("/hello/", async function (req, res) {
    res.send("Hello")
})


const router = express.Router()
router.get("/router/", async function (req, res) {
    res.send("Hello router")
})

app.use(router)


app.use("/hello2/", async function (req, res) {
    res.send("Hello2");
});

const PORT = 4444
app.listen(PORT, () => {
    console.log(`Example app listening at http://localhost:${PORT}`)
})

2. Visit web address

http://localhost:4444/hello/aaa
http://localhost:4444/router/
http://localhost:4444/hello2/aaa

3. see the skywalking dashboard

Anything else

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Labels

agentLanguage agent related.bugSomething isn't working and you are sure it's a bug!nodejsNodeJS backend agent related

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions