Fix app crashing when bot code causes an error#64
Conversation
|
I was going to use the error handler |
src/routes/index.ts
Outdated
| if (!handler) { | ||
| throw new Error(`invalid step ${step}`); | ||
| catch (e) { | ||
| if (e instanceof Error) { |
There was a problem hiding this comment.
what else might e be an instance of here?
There was a problem hiding this comment.
Oh yep - I don't need this line
src/routes/index.ts
Outdated
| if (!step) { | ||
| throw new Error('no step'); | ||
| try { | ||
| const { step } = DefaultRouteRequest.parse(req.body); |
There was a problem hiding this comment.
I'm kindof wondering if maybe the try/catch should only wrap this line? Like below you're throwing in a couple of other cases that this new block will catch. I'm not sure that's what you want to happen.
There was a problem hiding this comment.
With the step variable being used in the rest of the lines (except the await handler line), wouldn't they all have to be in the try block because of this? I was getting an error by only having the first line in try I think. I can move await handler outside the try catch block
App was crashing when botnet traffic tried to send information to TCPortal
The Fix: adding a try-catch block and logging the error instead of an error thrown inside the Zod code
Test plan:
Must have local operator running
Open Powershell ISE and paste this example script into the file:
Run
yarn euidin the terminal of the TCPortal code, then run the above script in ISE. Make sure the app does not crash, but instead logs the error and stays running. Go to the EUID TCPortal onlocalhost:3000, enter a valid email, and make sure the app is still working after the error.