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 job error handling #2502

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pshycodr
Copy link

@pshycodr pshycodr commented Feb 11, 2025

Fixes #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.

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).
@infomiho
Copy link
Contributor

Thanks for the contribution, did you test this locally successfully?

@pshycodr
Copy link
Author

Yes, I have tested these changes locally.
There were only a few minor Typescript errors on the mage/src/server/jobs/checkForPendingApps.ts file, which i resolved. Beyond those, I did not observe any further issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Introduce middleware for jobs (error handling)
2 participants