Skip to content

Conversation

@antongolub
Copy link
Collaborator

  • Tests pass
  • Appropriate changes to README are included in PR

@antongolub antongolub added the refactoring Internal code improvements label Jul 19, 2025
@antongolub antongolub requested a review from Copilot July 19, 2025 15:58
Copy link

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 introduces an internal isSync() method to the ProcessPromise class to improve code maintainability by encapsulating synchronous execution checks. The refactoring replaces direct access to the SYNC symbol with a centralized method and updates related logic for consistency.

  • Adds a private isSync() method to centralize synchronous execution detection
  • Updates all references to use the new method instead of direct snapshot[SYNC] access
  • Modifies the isHalted() logic to consider synchronous processes as non-halted

Reviewed Changes

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

Show a summary per file
File Description
src/core.ts Main refactoring with new isSync() method and updated logic
build/core.cjs Compiled JavaScript reflecting the TypeScript changes
test/util.test.js Adds test case for parseDuration(0)
docs/process-promise.md Updates timeout documentation with clarifications
.size-limit.json Updates bundle size limits reflecting code changes

if (this.isSettled()) throw new Error('Too late to abort the process.')
if (this.signal !== this._snapshot.ac?.signal)
const { ac } = this._snapshot
if (this.signal !== ac!.signal)
Copy link

Copilot AI Jul 19, 2025

Choose a reason for hiding this comment

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

Using non-null assertion operator (!) without proper null checking. The original code used optional chaining. Consider adding a null check: if (!ac || this.signal !== ac.signal) to handle cases where ac might be undefined.

Suggested change
if (this.signal !== ac!.signal)
if (!ac || this.signal !== ac.signal)

Copilot uses AI. Check for mistakes.
@antongolub antongolub merged commit d7d89c6 into google:main Jul 19, 2025
28 checks passed
@antongolub antongolub deleted the refactor-is-sync branch July 19, 2025 17:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

refactoring Internal code improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant