vscode-buf icon indicating copy to clipboard operation
vscode-buf copied to clipboard

formatting error: undefined

Open nutchanon-c opened this issue 1 year ago • 1 comments

When I'm trying to format, the output console shows undefined. I have no idea what's wrong. The extension was working fine the other day then it suddenly broke

image

nutchanon-c avatar Dec 16 '24 09:12 nutchanon-c

Hi, I can take a look at this. I am currently unable to repro this issue, do you mind providing a minimal repro and some more information (e.g. CLI version, system, etc.)?

doriable avatar Dec 17 '24 18:12 doriable

The reason for the error is in this code: const p = cp.spawn(this.binaryPath, ['format', backupFile], { cwd });

It is intended behavior for the security patch CVE-2024-27980. You must pass shell: true in the option on Windows environment if you need to spawn program ended with .bat or .cmd extension.

The patch is deployed in 18.20.2, 20.12.2, 21.17.3 and also 22.0.0 Details can be found on https://nodejs.org/en/blog/vulnerability/april-2024-security-releases-2

To fix this, simply add shell: process.platform === "win32" to the params.

const p = cp.spawn(this.binaryPath, ['format', backupFile], { cwd, shell: process.platform === "win32", });

clayzx avatar Apr 06 '25 17:04 clayzx

The fix from @clayzx has been merged and released, closing this issue for now. Please feel free to re-open if there are new questions/concerns.

doriable avatar May 14 '25 19:05 doriable