Skip to content

Conversation

@Uzlopak
Copy link
Contributor

@Uzlopak Uzlopak commented Sep 21, 2025

Disputable

This relates to...

Rationale

Changes

Features

Bug Fixes

Breaking Changes and Deprecations

Status

@Uzlopak Uzlopak requested a review from Copilot September 21, 2025 09:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR focuses on maintaining promise chains by ensuring that promise-returning functions properly return their promises instead of creating orphaned promises. The changes improve the async control flow by making promise chains chainable and preventing unhandled promise rejections.

  • Adds explicit return statements to promise chains that were previously orphaned
  • Refactors promise chain formatting for better readability and consistency
  • Introduces a reusable nop function to replace inline empty arrow functions

Reviewed Changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
lib/mock/snapshot-agent.js Reformats promise chain for better readability
lib/mock/mock-utils.js Adds missing return statement to promise chain
lib/interceptor/cache.js Introduces nop function and fixes promise chain returns
lib/dispatcher/pool-base.js Adds missing return statement to Promise.all
lib/dispatcher/dispatcher-base.js Reformats promise chains and removes unnecessary closures
lib/core/util.js Adds return statements to controller methods

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +618 to 620
return queueMicrotask(() => {
controller.close()
controller.byobRequest?.respond(0)
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

queueMicrotask doesn't return a value, so this return statement will return undefined. If a promise is expected, consider wrapping this in a Promise or removing the return statement.

Suggested change
return queueMicrotask(() => {
controller.close()
controller.byobRequest?.respond(0)
return new Promise(resolve => {
queueMicrotask(() => {
controller.close()
controller.byobRequest?.respond(0)
resolve()
})

Copilot uses AI. Check for mistakes.
const buf = Buffer.isBuffer(value) ? value : Buffer.from(value)
if (buf.byteLength) {
controller.enqueue(new Uint8Array(buf))
return controller.enqueue(new Uint8Array(buf))
Copy link

Copilot AI Sep 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

controller.enqueue() typically doesn't return a meaningful value for chaining. This return statement may not provide the expected behavior in the promise chain.

Suggested change
return controller.enqueue(new Uint8Array(buf))
controller.enqueue(new Uint8Array(buf))
return

Copilot uses AI. Check for mistakes.
@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 21, 2025

@metcoder95
I am hesitating to merge. I want to think about it a little.

@Uzlopak
Copy link
Contributor Author

Uzlopak commented Sep 22, 2025

I think it is ok. It doesnt make it worse.

@Uzlopak Uzlopak merged commit 1a9a4c0 into main Sep 22, 2025
28 of 29 checks passed
@Uzlopak Uzlopak deleted the return-promises branch September 22, 2025 17:08
@github-actions github-actions bot mentioned this pull request Jan 5, 2026
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.

3 participants