slackapi / bolt-js

A framework to build Slack apps using JavaScript
https://tools.slack.dev/bolt-js/
MIT License
2.74k stars 393 forks source link

bug: Issues with path-to-regexp after Bolt-JS upgrade to 3.21.4 #2267

Open nivr4 opened 1 month ago

nivr4 commented 1 month ago

Hey,

Recently, we upgraded Bolt-JS in our Slack app to version 3.21.4. Since then, we've been encountering the following error:

/ticketing-system/node_modules/path-to-regexp/dist/index.js:136
        throw new TypeError(`Unexpected ${nextType} at ${index}, expected ${type}: ${DEBUG_URL}`);
              ^

TypeError: Unexpected ? at 36, expected END: https://git.new/pathToRegexpError
    at Iter.consume (ticketing-system/node_modules/path-to-regexp/dist/index.js:136:15)
    at consume (ticketing-system/node_modules/path-to-regexp/dist/index.js:193:16)
    at parse (ticketing-system/node_modules/path-to-regexp/dist/index.js:197:20)
    at ticketing-system/node_modules/path-to-regexp/dist/index.js:308:74
    at Array.map (<anonymous>)
    at pathToRegexp (ticketing-system/node_modules/path-to-regexp/dist/index.js:308:25)
    at match (ticketing-system/node_modules/path-to-regexp/dist/index.js:278:30)
    at Server.<anonymous> ticketing-system/node_modules/@slack/bolt/dist/receivers/SocketModeReceiver.js:104:71)
    at Server.emit (node:events:515:28)
    at parserOnIncoming (node:_http_server:1143:12)

Do you have any suggestions for fixing this from our side, or should we downgrade to a previous version until the issue is resolved?

Thank you!

filmaj commented 1 month ago

If you could help us reproduce the problem, that would be helpful to understand what is happening.

It seems the stack trace points to code that runs in the default error handler in the Socket Mode receiver.

Can you share your App configuration, and steps on how to reproduce? What event triggers this error? Do you have any handlers defined in your for the particular event?

ShaiHalfon96 commented 2 weeks ago

Hi, I am working with Niv on this project. Currently we revert bolt version to 3.21.3 to avoid this errors. This is our app configuration:

const app = new App({
    token: config.SLACK_BOT_TOKEN,
    signingSecret: config.SLACK_SIGNING_SECRET,
    port: config.PORT,
    appToken: config.SLACK_APP_TOKEN,
    socketMode: true,
    customRoutes: customRoutes,
    logLevel: config.LOG_LEVEL,
    deferInitialization: true,
    logger: logger,
  });
filmaj commented 1 week ago

@ShaiHalfon96 how can I reproduce the error? Please provide reproduction instructions. If I cannot reproduce the error, I cannot help 😢

Does it happen on app startup? Does it happen when a specific event occurs? etc.