microsoft / microsoft/BotFramework-WebChat
Handler function missing third parameter in both `javascript/bot` and `javascript/web` of sample k.direct-line-token
@ram-xv is already working on this.
Since Sep 22, 2023.
- Dominant language
- HTML
- Stars
- 1.8k
- Forks
- 1.6k
- Avg merge
- 22h 58m
- Merged PRs (30d)
- 2
Description
Is it an issue related to Adaptive Cards?
No
Is this an accessibility issue?
No
What version of Web Chat are you using?
Latest production
Which distribution are you using Web Chat from?
Unrelated
Which hosting environment does this issue primarily affect?
Web apps
Which browsers and platforms do the issue happened?
Browser: Edge (latest)
Which area does this issue affect?
Protocol or service
What is the public URL for the website?
No response
Please describe the bug
In sample k.direct-line-token, the javascript web and bot project server routes and handlers were not functioning as expected, causing issues with server startup and request handling.
Environment:
- npm 8.19.4
- node v16.20.1
Do you see any errors in console log?
# npm start
> web@1.0.0 start
> node-dev --no-notify --respawn .
AssertionError [ERR_ASSERTION]: Handler [handler-1 on POST /api/messages] is missing a third argument (the "next" callback) but is not an async function. Middleware handlers can be either as
ync/await or callback-based.Callback-based (non-async) handlers should accept three arguments: (req, res, next). Async handler functions should accept maximum of 2 arguments: (req, res).
at Chain.add (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/chain.js:79:16)
at forEach (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/router.js:211:15)
at Array.forEach (<anonymous>)
at Router.mount (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/router.js:203:14)
at Server.serverMethod [as post] (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/restify/lib/server.js:1779:33)
at Object.<anonymous> (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/src/index.js:27:8)
at Module._compile (node:internal/modules/cjs/loader:1198:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1252:10)
at Object.nodeDevHook [as .js] (/Users/ram/Documents/bot/BotFramework-WebChat/samples/01.getting-started/k.direct-line-token/javascript/web/node_modules/node-dev/lib/hook.js:54:7)
at Module.load (node:internal/modules/cjs/loader:1076:32)
(node:68169) [DEP0111] DeprecationWarning: Access to process.binding('http_parser') is deprecated.
(Use `node --trace-deprecation ...` to show where the warning was created)
[ERROR] 00:02:19 AssertionError: Handler [handler-1 on POST /api/messages] is missing a third argument (the "next" callback) but is not an async function. Middleware handlers can be either a
sync/await or callback-based.Callback-based (non-async) handlers should accept three arguments: (req, res, next). Async handler functions should accept maximum of 2 arguments: (req, res).
How to reproduce the issue?
This issue reproduces in both javascript/web and javascript/bot in sample sample k.direct-line-token:
javascript/web
- Navigate to the root javascript/web project directory.
- Run
npm ithennpm startto start the server. - Send a request to the
/api/messagesroute. - Observe the error related to the missing third parameter in the handler function.
javascript/bot
- Navigate to the root javascript/bot project directory.
- Run
npm ithennpm startto start the server. - Send a request to the
/api/messagesroute. - Observe the error related to the missing third parameter in the handler function.
What do you expect?
Requests to the /api/messages route should be handled without errors.
What actually happened?
Received an error indicating the missing third parameter (next callback) in the handler function for the following files:
- javascript/bot: createBot.js.
- javascript/web: botMessages.js.
Do you have any screenshots or recordings to repro the issue?
No response
Adaptive Card JSON
No response
Additional context
This issue pertains to how Restify expects handler functions to be structured. The function should either be an async function with (req, res) or a callback-based function with (req, res, next).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.