-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix app crashing when bot code causes an error #64
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what else might e be an instance of here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 euid
in 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.