Add missing function argument to remove runtime error on linux desktop #1556
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I get the following error on the latest release of DIVE when running a long-running stereo pipeline.
This is an Express error handler but it has the wrong signature. Express error handlers need 4 parameters: (err, req, res, next). With only 3 parameters, Express treats it as a regular middleware and passes (req, res, next) - so the request object becomes err, the response object becomes req, and next becomes res.
Update(client/platform/desktop/backend/server.ts)
Updated client/platform/desktop/backend/server.ts with 2 additions
211 err: { status?: number; statusMessage?: string },
212 req: express.Request,
213 res: express.Response,
214 + // eslint-disable-next-line @typescript-eslint/no-unused-vars
215 + next: express.NextFunction,
216 ) {
217 res.status(err.status || 500).json({ message: err.statusMessage || err });
218 }
The fix is adding the next parameter. In Express, error-handling middleware must have exactly 4 parameters (err, req, res, next) for Express to recognize it as an error handler. Without next, Express was treating fail as regular middleware and passing (req, res, next) instead of (err, req, res, next), causing res to be in the req position and the actual next function to be in the res position.
When the code then called res.status(500), it was actually calling next.status(500) - and next is a function, not a response object, which is why you got TypeError: n.status is not a function.