Skip to content

Fix logical bug in checksums environment variable handling in npm/install.js #48594

@KinshukSS2

Description

@KinshukSS2

Preflight Checklist

Electron Version

36.0.0 and above

What operating system(s) are you using?

Ubuntu

Operating System Version

Ubuntu 25.04

What arch are you using?

x86_64

Expected Behavior

This makes the intent clearer:
if either environment variable is truthy, skip local checksums

checksums: (process.env.electron_use_remote_checksums || process.env.npm_config_electron_use_remote_checksums) ? undefined : require('./checksums.json'),

Actual Behavior

There is a logical bug in install.js line 47 where the environment variable check for electron_use_remotechecksums doesn't work correctly due to operator precedence

The ternary operator (?:) has lower precedence than the nullish coalescing operator (??), so the code is evaluated as:

checksums: (process.env.electron_use_remote_checksums ?? process.env.npm_config_electron_use_remote_checksums) ? undefined : require('./checksums.json')

  • If either variable is set to a truthy value, it uses remote checksums
  • But the logic is confusing and not what was likely intended

Metadata

Metadata

Assignees

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions