Fix asyncHandler to ensure middleware is called on next tick to prevent in-tick throws

Open Beginner friendly
#84 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
63/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
express, javascript
Domain
api, backend

Research direction

Read lib/index.js lines 587–615, where asyncHandler calls the middleware. Check how synchronous throws and calls to next behave, then compare them with next-tick or asynchronous calls. Done when middleware is invoked on the next tick and those behaviors are consistent.

Written by the indexing model from the issue text.

Description

const result = middleware(...args); might still throw for any code executed on the same tick -- and the middleware itself might be entirely synchronous. Also, next won't be modified until after the middleware is called, so in-tick calls to next will behave differently to next-tick/async calls.

See: https://github.com/digitalbazaar/bedrock-express/blob/v8.8.1/lib/index.js#L587-L615

Dominant language
JavaScript
Stars
0
Forks
3
Avg merge
2h 25m
Merged PRs (30d)
3

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from digitalbazaar/bedrock-express

All issues in digitalbazaar/bedrock-express

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.