Skip to content

test: refactor client-request.js#4500

Open
Uzlopak wants to merge 2 commits intomainfrom
client-request
Open

test: refactor client-request.js#4500
Uzlopak wants to merge 2 commits intomainfrom
client-request

Conversation

@Uzlopak
Copy link
Copy Markdown
Contributor

@Uzlopak Uzlopak commented Sep 1, 2025

This relates to...

Rationale

Changes

Features

Bug Fixes

Breaking Changes and Deprecations

Status

@Uzlopak Uzlopak requested a review from Copilot September 6, 2025 06:45
Copy link
Copy Markdown
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 refactors the test file test/client-request.js to modernize its testing patterns and improve consistency. The main purpose is to replace callback-based server listening patterns with promise-based approaches using once() from Node.js events, and to consolidate import statements.

  • Replace callback-based server.listen() patterns with await once(server.listen(0), 'listening')
  • Consolidate and reorganize import statements at the top of the file
  • Remove redundant closing braces from callback-based patterns

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

Comment thread test/client-request.js
})

test('request with FormData body', async (t) => {
t = tspl(t, { plan: 5 })
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

The plan count of 5 appears incorrect. Based on the test logic, there are no explicit assertions being made in this test that would require 5 planned test cases. This could cause the test to hang or fail unexpectedly.

Copilot uses AI. Check for mistakes.
Comment thread test/client-request.js
Comment on lines +1314 to +1316
queueMicrotask(() => {
res.end(data.slice(1))
})
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Using queueMicrotask() instead of setTimeout() changes the timing behavior significantly. queueMicrotask() executes immediately after the current execution stack, while setTimeout() provided a 100ms delay. This could affect the test's ability to properly test multibyte handling across chunks.

Copilot uses AI. Check for mistakes.
Comment thread test/client-request.js
Comment on lines +1340 to +1342
queueMicrotask(() => {
res.end(data.slice(1))
})
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Similar to the previous test, replacing setTimeout() with queueMicrotask() changes the timing behavior. The original 100ms delay may have been intentional to test how the client handles chunked multibyte data over time.

Copilot uses AI. Check for mistakes.
Comment thread test/client-request.js
Comment on lines +1366 to +1368
queueMicrotask(() => {
res.end(data.slice(1))
})
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Again, replacing setTimeout() with queueMicrotask() changes the timing behavior. This could impact the test's effectiveness in validating multibyte text handling with different encodings when data arrives in separate chunks.

Copilot uses AI. Check for mistakes.
Comment thread test/client-request.js
res.write('hello from server')
res.end()
}, 100)
}, Infinity)
Copy link

Copilot AI Sep 6, 2025

Choose a reason for hiding this comment

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

Using Infinity as the timeout value will cause the server to never send a response, which will likely cause the test to hang indefinitely. The original 100ms timeout was probably intentional to allow the abort signal to be tested properly.

Suggested change
}, Infinity)
}, 100)

Copilot uses AI. Check for mistakes.
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.

2 participants