Skip to content

refactor(server): middleware early-returns object instead of setting ctx.body#976

Open
LucciHank wants to merge 1 commit intopastelsky:bundlephobiafrom
LucciHank:contribai/improve/quality/middleware-early-returns-object-instead-
Open

refactor(server): middleware early-returns object instead of setting ctx.body#976
LucciHank wants to merge 1 commit intopastelsky:bundlephobiafrom
LucciHank:contribai/improve/quality/middleware-early-returns-object-instead-

Conversation

@LucciHank
Copy link
Copy Markdown

Description

if (peek) returns {name, version, peekSuccess: false} but never sets ctx.body or calls next(). In Koa the return value is ignored, so the client receives no body (empty response or 404). The code was clearly intended to short-circuit with a response object.

Changes

  • server/middlewares/exportsSizes.middleware.js (modified)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Testing

  • Code follows the style guidelines of this project
  • Self-review of code completed
  • Changes generate no new warnings
  • Corresponding changes to documentation made (if applicable)

Severity: high

Contributed by Lê Thành Chỉnh
Code is a tool. Mindset is the real value.

Closes #975

if (peek) returns {name, version, peekSuccess: false} but never sets ctx.body or calls next(). In Koa the return value is ignored, so the client receives no body (empty response or 404). The code was clearly intended to short-circuit with a response object.

Affected files: exportsSizes.middleware.js

Signed-off-by: Hoangg Anh <131897682+LucciHank@users.noreply.github.com>
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.

fix: middleware early-returns object instead of setting ctx.body

1 participant