Skip to content

Fix temp file collisions during concurrent evals - #20

Open
tuanvumaihuynh wants to merge 1 commit into
silships:mainfrom
tuanvumaihuynh:fix-temp-file-race
Open

Fix temp file collisions during concurrent evals#20
tuanvumaihuynh wants to merge 1 commit into
silships:mainfrom
tuanvumaihuynh:fix-temp-file-race

Conversation

@tuanvumaihuynh

Copy link
Copy Markdown

Summary

  • Generate unique temp filenames for eval payload, script, and result files.
  • Include process id, timestamp, and random bytes to avoid filename collisions across concurrent CLI invocations.

Why

Concurrent commands can create temp files in the same millisecond when filenames only use Date.now(). That can cause one process to read, overwrite, or remove another process's payload/result file.

Validation

  • node --check src/index.js
  • npm test
  • Ran multiple concurrent verify commands against different Figma frames and confirmed each returned the expected frame id/name.
  • Ran multiple concurrent eval commands with distinct payloads and confirmed responses stayed isolated.

Copilot AI review requested due to automatic review settings May 28, 2026 06:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a helper to generate more unique temp file names and updates Figma evaluation code paths to use it.

Changes:

  • Introduces tmpName(prefix, ext) for temp file path generation using PID/time/random bytes
  • Switches temp payload/script/result filenames in figmaEvalSync to tmpName(...)

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

Comment thread src/index.js
Comment on lines +33 to +35
function tmpName(prefix, ext) {
return join(tmpdir(), `${prefix}-${process.pid}-${Date.now()}-${randomBytes(6).toString('hex')}.${ext}`);
}
Comment thread src/index.js
Comment on lines +33 to +35
function tmpName(prefix, ext) {
return join(tmpdir(), `${prefix}-${process.pid}-${Date.now()}-${randomBytes(6).toString('hex')}.${ext}`);
}
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