Skip to content
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

Extension breaks other extensions due to using Regexp shim #853

Open
j-fulbright opened this issue Jun 19, 2024 · 5 comments
Open

Extension breaks other extensions due to using Regexp shim #853

j-fulbright opened this issue Jun 19, 2024 · 5 comments

Comments

@j-fulbright
Copy link

After reviewing an error for a different extension, it was determined that the extension was broken due to TODO Tree.

From the other extension author:

gruntfuggly is using a package called [regexp-match-indices](https://www.npmjs.com/package/regexp-match-indices) which replaces the javascript RegExp object globally and causes unexpected behaviour in RegExp.exec().

Versionlens uses a RegExp with the flags /gd which are valid [RegExp flags](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Regular_expressions#regex_flags)
but the shim gruntfuggly uses doesn't support them....

its very bad that this extension replaces the RegExp object globally. 
This will potentially cause many problems in vscode.

This particular usage here:

var execWithIndices = require( "regexp-match-indices" ).shim();

@sa2taka
Copy link

sa2taka commented Jun 25, 2024

I'm also seeing.

@Release-Candidate
Copy link

Release-Candidate commented Jul 2, 2024

It breaks my extension too: Release-Candidate/vscode-scheme-repl#20

The problem for me are the valid flagsdsu.

The stack-trace from "OUTPUT" of "Extension Host":

[error] SyntaxError: Invalid flags: dsu
	at k (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:74341)
	at Array.d (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:3580)
	at Object.parse (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:71938)
	at r.parse (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:1:12692)
	at Object.parse (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:415)
	at l (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:165)
	at Array.get [as indices] (/home/roland/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:2895)
	at Re (/home/roland/tmp/vscode-scheme-repl/out/extension.js:16:2643)
	at zr (/home/roland/tmp/vscode-scheme-repl/out/extension.js:16:210)
	at g (/home/roland/tmp/vscode-scheme-repl/out/extension.js:12:1237)
	at Y (/home/roland/tmp/vscode-scheme-repl/out/extension.js:16:2259)
	at vr (/home/roland/tmp/vscode-scheme-repl/out/extension.js:12:1338)
	at g (/home/roland/tmp/vscode-scheme-repl/out/extension.js:12:1070)
	at U (/home/roland/tmp/vscode-scheme-repl/out/extension.js:12:956)
	at Ne (/home/roland/tmp/vscode-scheme-repl/out/extension.js:25:918)
	at /home/roland/tmp/vscode-scheme-repl/out/extension.js:830:29871

@boltex
Copy link

boltex commented Aug 24, 2024

Also happens for my extensions "LeoJS" https://github.com/boltex/leojs .

Specifically, I'm getting the "Invalid flags: dgm" error messages, which renders my extension somehow unresponsive!

@pedrohenrique-ql
Copy link

This also happens in my extension Regex Match, which uses the /d flag to get the match indexes.

Reported in pedrohenrique-ql/vscode-regex-match#95.

The error:

2024-09-11 20:05:50.222 [error] SyntaxError: Invalid flags: dg
    at k (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:74341)
    at Array.d (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:3580)
    at Object.parse (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:71938)
    at Object.r.parse (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:1:12692)
    at Object.parse (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:114:415)
    at l (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:165)
    at Array.get [as indices] (/home/pedrohql/.vscode/extensions/gruntfuggly.todo-tree-0.0.226/dist/extension.js:52:2895)
    at RegexTest.processMatch (/home/pedrohql/projects/regex-match/src/services/regex-match/RegexTest.ts:92:15)
    at RegexTest.test (/home/pedrohql/projects/regex-match/src/services/regex-match/RegexTest.ts:47:37)
    at /home/pedrohql/projects/regex-match/src/decorations/TextDecorationApplier.ts:19:72
    at Array.flatMap (<anonymous>)
    at Function.updateDecorations (/home/pedrohql/projects/regex-match/src/decorations/TextDecorationApplier.ts:19:39)
    at RegexMatchService.updateRegexTest (/home/pedrohql/projects/regex-match/src/services/regex-match/RegexMatchService.ts:79:27)
    at RegexMatchService.openRegexTestWindow (/home/pedrohql/projects/regex-match/src/services/regex-match/RegexMatchService.ts:74:10)
    at d.h (/usr/share/code/resources/app/out/vs/workbench/api/node/extensionHostProcess.js:154:206473) regex-match.openRegexMatchWindow {"value":"pedrohenrique-ql.regex-match","_lower":"pedrohenrique-ql.regex-match"}

@AlfishSoftware
Copy link

This is also breaking my extension. Upstream issue: rbuckton/regexp-match-indices#15
Can you please fix with an update, @rbuckton? Last update was 5 years ago, so it should be fixed or deprecated.

Better yet, just not use the dependency, since the shim is no longer necessary, I assume?

It's absurd that this sort of thing can happen at all, you'd think extensions should run isolated from each other?
This goes to show how you should never mess with JS globals. If you want to polyfill something, use your own classes.

Is there any way to ensure I'm using vanilla RegEx/Array?

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

No branches or pull requests

6 participants