GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix: prevent race conditions for concurrent npm-based server processes using same `node_modules` dir by simschla · Pull Request #2786 · diffplug/spotless

Conversation

@simschla

@simschla simschla commented Dec 9, 2025

Copy link
Copy Markdown
Contributor

In #2462 and #2542 we added support for multiple npm-based formatters sharing the same node_modules directory.
In my projects I noticed that - every once in a while - some of the npm-server-processes failed to start. This happened more often when configuration cache was active (and hence processes started faster). The lint files showed the following messages (example):

Process result:
> arguments: [/path/to/repo/.gradle/nodejs/node-v24.11.1-darwin-arm64/bin/npm, start, --scripts-prepend-node-path=true, --, --node-server-instance-id=d61a85af-5417-40d9-9fa7-369ded8b7921]
> exit code: 0
>    stdout: (below)
> npm warn Unknown cli config "--scripts-prepend-node-path". This will stop working in the next major version of npm.
> 
> > [email protected] start
> > node serve.js --node-server-instance-id=***
> 
> [Error: ENOENT: no such file or directory, rename 'server.port.tmp' -> 'server-d61a85af-5417-40d9-9fa7-369ded8b7921.port'] {
>   errno: -2,
>   code: 'ENOENT',
>   syscall: 'rename',
>   path: 'server.port.tmp',
>   dest: 'server-d61a85af-5417-40d9-9fa7-369ded8b7921.port'
> }

This PR fixes this race condition by making sure that the server-processes do not collide on the server.port.tmp file anymore, no matter the timing.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
simschla added 4 commits December 9, 2025 20:45
@simschla
fix: prevent name collisions when launching multiple node-based serve…
91d568a
…rs on same node_modules

Before this change: if two (or more) node-based servers have been
started on the same node_modules dir, the could override each others
temporary port files, resulting in some of the servers not correctly
launching.
With this change: each server process makes sure to write distinct
temporary and final files for transporting selected port number to the
launching java process.
This is a fixup for diffplug#2462.

Refs: diffplug#2462, diffplug#2542
@simschla
chore: bump versions for serve-packages due to logic changes
1c0870f
Refs: diffplug#2462, diffplug#2542
@simschla
docs: add fix to changelog
c70dee0
@simschla
docs: use assigned PR number
7b9e99b
@simschla
simschla requested a review from Copilot December 9, 2025 20:03
Copilot started reviewing on behalf of simschla December 9, 2025 20:03
View session
@simschla simschla changed the title fix: prevent name collisions for concurrent npm-based server processes fix: prevent race conditions for concurrent npm-based server processes using same node_modules dir Dec 9, 2025
Copilot AI reviewed Dec 9, 2025
View reviewed changes

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this 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 fixes a race condition that occurred when multiple npm-based formatters (prettier, eslint, tsfmt) launch their server processes simultaneously while sharing the same node_modules directory. The issue manifested as "ENOENT: no such file or directory, rename 'server.port.tmp'" errors because concurrent processes were colliding on the shared temporary filename.

Key Changes:

  • Fixed race condition by including the instance ID in the temporary port filename
  • Bumped npm package versions from 4.0.0 to 4.0.1 for all three formatters
  • Updated changelog entries across all affected components

Reviewed changes

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

Show a summary per file
File Description
lib/src/main/resources/com/diffplug/spotless/npm/common-serve.js Core fix: changed server.port.tmp to use instance-specific filenames like server-{instanceId}.port.tmp to prevent concurrent access collisions
lib/src/main/resources/com/diffplug/spotless/npm/eslint-package.json Version bump from 4.0.0 to 4.0.1 to reflect the bug fix
lib/src/main/resources/com/diffplug/spotless/npm/prettier-package.json Version bump from 4.0.0 to 4.0.1 to reflect the bug fix
lib/src/main/resources/com/diffplug/spotless/npm/tsfmt-package.json Version bump from 4.0.0 to 4.0.1 to reflect the bug fix
CHANGES.md Added entry documenting the race condition fix
plugin-gradle/CHANGES.md Added entry documenting the race condition fix for gradle plugin users
plugin-maven/CHANGES.md Added entry documenting the race condition fix for maven plugin users

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@simschla

simschla commented Jan 5, 2026

Copy link
Copy Markdown
Contributor Author

OK to merge for you @nedtwigg ?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nedtwigg
nedtwigg merged commit 1b53132 into diffplug:main Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

Copilot code review Copilot
Copilot review effort
Applies to this pull request for everyone.Learn more about Copilot code review.
Copilot left review comments

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@simschla @nedtwigg
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.