You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to add HTTP routes to a Probot app deployed to AWS Lambda with your adapter. The HTTP route /api/hello-world added works when deploying the app locally with nodemon src/index.ts. However, the endpoint returns the error 500 when deployed to AWS Lambda with Serverless because getRouter is undefined.
2022-10-16T19:17:01.251Z undefined ERROR Unhandled Promise Rejection { "errorType": "Runtime.UnhandledPromiseRejection", "errorMessage": "Error: getRouter is undefined", "reason": { "errorType": "Error", "errorMessage": "getRouter is undefined", "stack": [ "Error: getRouter is undefined", " at /var/task/src/index.js:9:15", " at Generator.next (<anonymous>)", " at /var/task/node_modules/tslib/tslib.js:118:75", " at new Promise (<anonymous>)", " at Object.__awaiter (/var/task/node_modules/tslib/tslib.js:114:16)", " at challengeBot (/var/task/src/index.js:7:54)", " at Probot.load (/var/task/node_modules/probot/lib/probot.js:80:16)", " at createLambdaFunction (/var/task/node_modules/@probot/adapter-aws-lambda-serverless/index.js:14:10)", " at Object.<anonymous> (/var/task/src/lambda/handler.js:5:84)", " at Module._compile (node:internal/modules/cjs/loader:1105:14)" ] }, "promise": {}, "stack": [ "Runtime.UnhandledPromiseRejection: Error: getRouter is undefined", " at process.<anonymous> (file:///var/runtime/index.mjs:1131:17)", " at process.emit (node:events:527:28)", " at process.emit (node:domain:475:12)", " at emit (node:internal/process/promises:140:20)", " at processPromiseRejections (node:internal/process/promises:274:27)", " at processTicksAndRejections (node:internal/process/task_queues:97:32)" ]}
Is this behavior to be expected when using this adatper and deploying on AWS lambda? Probot doc mentions that getRouter will be set only when running the app with probot run or using their Server.
src/index.ts:
import{ApplicationFunctionOptions,Probot,run}from'probot';import*asexpressfrom'express';exportconstchallengeBot=async(app: Probot,{ getRouter }: ApplicationFunctionOptions): Promise<void>=>{if(!getRouter){thrownewError('getRouter is undefined');}constrouter=getRouter('/api');router.use(express.json());router.get('/hello-world',(req,res)=>{res.json({a: 1});});app.on('issues.opened',async(context)=>{constissueComment=context.issue({body: 'Thanks for opening this issue!',});awaitcontext.octokit.issues.createComment(issueComment);});};run(challengeBot);
The text was updated successfully, but these errors were encountered:
This statement is shedding some light on the issue reported:
We will likely remove the getRouter function in a future Probot version altogether as it cannot be supported in serverless environments. We will instead ask people to use the Server export instead and define their custom routes that way.
I'm trying to add HTTP routes to a Probot app deployed to AWS Lambda with your adapter. The HTTP route
/api/hello-world
added works when deploying the app locally withnodemon src/index.ts
. However, the endpoint returns the error 500 when deployed to AWS Lambda with Serverless becausegetRouter
is undefined.Is this behavior to be expected when using this adatper and deploying on AWS lambda? Probot doc mentions that
getRouter
will be set only when running the app withprobot run
or using theirServer
.src/index.ts
:The text was updated successfully, but these errors were encountered: