Skip to content

Fix data race via RequiresAddingImplicitUndefined #1152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 10, 2025
Merged

Conversation

jakebailey
Copy link
Member

Fixes #1151

Copy link
Contributor

@Copilot 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 a mutex-protected public wrapper for RequiresAddingImplicitUndefined and refactors the underlying private logic to fix a data race.

  • Adds RequiresAddingImplicitUndefined with locking in emitresolver.go
  • Renames and refactors the original logic into requiresAddingImplicitUndefined and requiresAddingImplicitUndefinedWorker
  • Updates the builder to call the (now private) requiresAddingImplicitUndefined

Reviewed Changes

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

File Description
internal/checker/nodebuilderimpl.go Calls the private requiresAddingImplicitUndefined instead of the public, locked wrapper
internal/checker/emitresolver.go Adds a locked public RequiresAddingImplicitUndefined and refactors private methods
Comments suppressed due to low confidence (1)

internal/checker/nodebuilderimpl.go:1901

  • This call bypasses the mutex by invoking the private requiresAddingImplicitUndefined directly. To ensure thread safety, restore calling the public RequiresAddingImplicitUndefined, which acquires the lock.
addUndefinedForParameter := declaration != nil && (ast.IsParameter(declaration) /*|| ast.IsJSDocParameterTag(declaration)*/) && b.ch.GetEmitResolver(nil, true).requiresAddingImplicitUndefined(declaration, symbol, b.ctx.enclosingDeclaration)

@jakebailey jakebailey enabled auto-merge June 10, 2025 18:27
Copy link
Member

@weswigham weswigham left a comment

Choose a reason for hiding this comment

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

I did this for a bunch of other entrypoints, so this tracks, but where is this showing up?

@jakebailey
Copy link
Member Author

It's blocked three PRs from merging so far; the race message is in #1151.

@jakebailey jakebailey added this pull request to the merge queue Jun 10, 2025
Merged via the queue into main with commit af2ec35 Jun 10, 2025
23 checks passed
@jakebailey jakebailey deleted the jabaile/fix-1151 branch June 10, 2025 19:09
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.

Data race in RequiresAddingImplicitUndefined
2 participants