Skip to content
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

Introduce middleware for jobs (error handling) #2475

Open
infomiho opened this issue Jan 30, 2025 · 0 comments
Open

Introduce middleware for jobs (error handling) #2475

infomiho opened this issue Jan 30, 2025 · 0 comments
Labels
enhancement New feature or request jobs

Comments

@infomiho
Copy link
Contributor

infomiho commented Jan 30, 2025

Users have to wrap their job handlers in try catch blocks to get error logging. We should investigate the best way to provide some sort of default error logging (to avoid jobs crashing the server, I'd assume).

One way a user suggested it to introduce some sort of jobs middleware e.g. you wrap jobs by default in error handling.

Related Discord thread: https://ptb.discord.com/channels/686873244791210014/867713251479519232/1334242360263049248

@infomiho infomiho added the jobs label Jan 30, 2025
@infomiho infomiho changed the title Introduce error handling in jobs Introduce middleware for jobs (error handling) Jan 30, 2025
@Martinsos Martinsos added the enhancement New feature or request label Feb 5, 2025
pshycodr added a commit to pshycodr/wasp that referenced this issue Feb 11, 2025
Fixes wasp-lang#2475

Introduce default error logging middleware for jobs to avoid server crashes.

* Add `errorLoggingMiddleware` function in `waspc/data/Generator/templates/sdk/wasp/server/middleware/globalMiddleware.ts` to log errors and prevent job crashes.
* Update `mage/src/server/jobs/checkForPendingApps.ts` to wrap the `checkForPendingApps` job handler with `errorLoggingMiddleware`.
* Update `mage/src/server/jobs/failStaleGenerations.ts` to wrap the `failStaleGenerations` job handler with `errorLoggingMiddleware`.
* Update documentation in `web/docs/advanced/jobs.md` to include information about the new default error logging middleware for jobs.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/wasp-lang/wasp/issues/2475?shareId=XXXX-XXXX-XXXX-XXXX).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request jobs
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants