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

Reloading extension host results in "Unable to open polyfills.js" error notification #105047

Closed
mattacosta opened this issue Aug 20, 2020 · 25 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Milestone

Comments

@mattacosta
Copy link
Contributor

Issue Type: Bug

Steps to reproduce:

  1. Start up the extension development host.
  2. Press ctrl+r to reload.
  3. The debugging window reports the following notification, and the extension host does not load the extension. This only happens on every other reload, so it alternates between loading correctly and throwing this error.
Unable to open 'polyfills.js': Unable to read file 'c:\Users\Matt\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\node_modules.asar\graceful-fs\polyfills.js' (Error: Unable to resolve non-existing file 'c:\Users\Matt\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\node_modules.asar\graceful-fs\polyfills.js').

VS Code version: Code - Insiders 1.49.0-insider (f694b07, 2020-08-19T05:47:42.278Z)
OS version: Windows_NT x64 10.0.19041

@weinand weinand added the debug Debug viewlet, configurations, breakpoints, adapter issues label Aug 20, 2020
@weinand
Copy link
Contributor

weinand commented Aug 20, 2020

I cannot reproduce this on Windows.
Could you please try to reproduce this with the unmodified "hello world" extension (https://code.visualstudio.com/api/get-started/your-first-extension).
If the problem doesn't exist there, then it is most likely a problem with your extension.

@weinand weinand added the info-needed Issue requires more information from poster label Aug 20, 2020
@mattacosta
Copy link
Contributor Author

Hmm, I can't reproduce using the hello world extension either.

That said, debugging shows a promise rejection with this message being thrown:
"ENOENT: no such file or directory, stat 'c:\\Users\\Matt\\AppData\\Roaming\\Code - Insiders\\logs\\20200819T190415\\exthost9\\output_logging_20200820T034543'"

...which is highly unlikely to be something my extension is directly accessing.

Call stack:

<anonymous> (Unknown Source:280)
callback (c:\Users\Matt\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\node_modules.asar\graceful-fs\polyfills.js:295)
<anonymous> (<node_internals>/original-fs.js:158)

Since the first entry is grayed out, the second is automatically selected. Could this be related to the call stack's tree view item?

Console entry:
notificationsAlerts.ts:40 Unable to open 'polyfills.js': Unable to read file 'c:\Users\Matt\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\node_modules.asar\graceful-fs\polyfills.js' (Error: Unable to resolve non-existing file 'c:\Users\Matt\AppData\Local\Programs\Microsoft VS Code Insiders\resources\app\node_modules.asar\graceful-fs\polyfills.js').
onDidChangeNotification @ breadcrumbsModel.ts:307
(anonymous) @ breadcrumbsModel.ts:307
fire @ event.ts:584
addNotification @ notifications.ts:188
notify @ notificationService.ts:69
doHandleOpenEditorError @ editorGroupView.ts:1018
(anonymous) @ editorGroupView.ts:923
async function (async)
(anonymous) @ editorGroupView.ts:923
doShowEditor @ editorGroupView.ts:923
doOpenEditor @ editorGroupView.ts:923
openEditor @ editorGroupView.ts:880
openEditor @ editorService.ts:509
openInEditor @ debugSource.ts:71
openInEditor @ debugModel.ts:350
focusStackFrame @ debugService.ts:753
n @ debugSession.ts:770
(anonymous) @ debugSession.ts:825
async function (async)
(anonymous) @ debugSession.ts:770
fire @ event.ts:584
(anonymous) @ rawDebugSession.ts:123
processQueue @ abstractDebugAdapter.ts:152
async function (async)
processQueue @ abstractDebugAdapter.ts:152
acceptMessage @ abstractDebugAdapter.ts:54
$acceptDAMessage @ mainThreadDebugService.ts:254
_doInvokeHandler @ rpcProtocol.ts:401
_invokeHandler @ rpcProtocol.ts:332
_receiveRequest @ rpcProtocol.ts:278
_receiveOneMessage @ rpcProtocol.ts:220
(anonymous) @ rpcProtocol.ts:93
fire @ event.ts:584
fire @ ipc.net.ts:412
_receiveMessage @ ipc.net.ts:746
(anonymous) @ ipc.net.ts:599
fire @ event.ts:584
acceptChunk @ ipc.net.ts:231
(anonymous) @ ipc.net.ts:157
t @ ipc.net.ts:822
emit @ events.js:223
addChunk @ _stream_readable.js:309
readableAddChunk @ _stream_readable.js:290
Readable.push @ _stream_readable.js:224
onStreamRead @ internal/stream_base_commons.js:181

@Paril
Copy link

Paril commented Aug 26, 2020

I get this quite often while trying F5 our extension as well. Same error as the OP.

@tjx666
Copy link
Contributor

tjx666 commented Sep 12, 2020

Same here

@tjx666
Copy link
Contributor

tjx666 commented Sep 12, 2020

image

@tjx666
Copy link
Contributor

tjx666 commented Sep 12, 2020

Version Infos:

Version: 1.49.0 (user setup)
Commit: e790b931385d72cf5669fcefc51cdf65990efa5d
Date: 2020-09-10T13:22:08.892Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.19041

The reproduce steps is same as @mattacosta said.

My extension repository: https://github.com/tjx666/vscode-fe-helper

@connor4312
Copy link
Member

Can you collect a trace log using the following instructions?

If you're able to, add "trace": true to your launch.json and reproduce the issue. The location of the log file on your disk will be written to the Debug Console. Share that with us.

⚠️ This log file will not contain source code, but will contain file paths. You can drop it into https://microsoft.github.io/vscode-pwa-analyzer/index.html to see what it contains. If you'd rather not share the log publicly, you can email it to connor@xbox.com

@tjx666
Copy link
Contributor

tjx666 commented Sep 13, 2020

@connor4312
Copy link
Member

connor4312 commented Sep 13, 2020

Thanks. It looks like you have pause on exception setup, and it's actually pausing on the error that you saw above

(cc @sandy081 on that -- I think you're the right person?)

I think the electron-shimmed fs lets us read files in the .asar, so we report c:\applications\Microsoft VS Code\resources\app\node_modules.asar\graceful-fs\polyfills.js as existing, when it should not exist. I'll put that fix into the debugger.

@connor4312 connor4312 added bug Issue identified by VS Code Team member as probable bug and removed info-needed Issue requires more information from poster labels Sep 13, 2020
@connor4312 connor4312 added this to the September 2020 milestone Sep 13, 2020
@sandy081
Copy link
Member

I think you're the right person?

You are right. Please let me know how can I help here.

@tansaku
Copy link

tansaku commented Sep 18, 2020

I'm getting this same issue on OSX 10.15.6 (19G2021)

@connor4312
Copy link
Member

@sandy081 I think the thing for you would be to look at why that error is being thrown and avoid doing so 🙂

The task for me is to not have it open the "Unable to open 'polyfills.js': Unable to read file " editor, and instead open the file with correct contents.

@connor4312 connor4312 assigned sandy081 and unassigned weinand Sep 18, 2020
connor4312 added a commit to microsoft/vscode-js-debug that referenced this issue Sep 18, 2020
@connor4312
Copy link
Member

This is now done

@connor4312 connor4312 removed their assignment Sep 18, 2020
@mikededo
Copy link

I'm facing the same issue. How can it be solved?

@boltex
Copy link

boltex commented Sep 22, 2020

I'm also getting this issue on ubuntu 18.04 with this extension https://github.com/boltex/leointeg (dev branch)

Complete message is
Unable to open 'polyfills.js': Unable to read file '/usr/share/code/resources/app/node_modules.asar/graceful-fs/polyfills.js' (EntryNotADirectory (FileSystemError): Error: ENOTDIR: not a directory, stat '/usr/share/code/resources/app/node_modules.asar/graceful-fs/polyfills.js').

heres a screenshot:

Screenshot from 2020-09-22 00-58-11

edit: specs below
Version: 1.49.1
Commit: 58bb7b2
Date: 2020-09-16T23:23:33.049Z
Electron: 9.2.1
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Linux x64 5.7.1-050701-generic

@connor4312
Copy link
Member

How can it be solved?

You can uncheck "uncaught exceptions" in the breakpoints view. Adding "skipFiles": ["**/node_modules.asar/**"], to your launch.json may also work, though I can't reproduce this at the moment to verify that.

@sandy081
Copy link
Member

@connor4312 Is it possible to get the stack trace of the error here, it would be interesting to know where is this error being thrown.

@connor4312
Copy link
Member

Here's the trace from a log someone posted above. Unfortunately it doesn't look like CDP gives us the async stack trace in this scenario...

[
  {
    "id": 1,
    "name": "<anonymous>",
    "line": 280,
    "column": 18,
    "presentationHint": "normal"
  },
  {
    "id": 2,
    "name": "callback",
    "line": 295,
    "column": 20,
    "source": {
      "name": "c:\\applications\\Microsoft VS Code\\resources\\app\\node_modules.asar\\graceful-fs\\polyfills.js",
      "path": "c:\\applications\\Microsoft VS Code\\resources\\app\\node_modules.asar\\graceful-fs\\polyfills.js",
      "sourceReference": 0
    },
    "presentationHint": "normal"
  },
  {
    "id": 3,
    "name": "<anonymous>",
    "line": 158,
    "column": 21,
    "source": {
      "name": "<node_internals>/original-fs.js",
      "path": "<node_internals>/original-fs.js",
      "sourceReference": 1200056501
    },
    "presentationHint": "normal"
  }
]

@tjx666
Copy link
Contributor

tjx666 commented Sep 22, 2020

This issue greatly affects my creative experience of vscode extension.

@sandy081
Copy link
Member

@connor4312 I looked into the code that creates above directory and I see it is safely wrapped with try/catch block and handling errors.

private async _doCreateOutChannel(name: string): Promise<AbstractExtHostOutputChannel> {
try {
const outputDirPath = join(this._logsLocation.fsPath, `output_logging_${toLocalISOString(new Date()).replace(/-|:|\.\d+Z$/g, '')}`);
const outputDir = await dirExists(outputDirPath).then(exists => exists || mkdirp(outputDirPath).then(() => true)).then(() => outputDirPath);
const fileName = `${this._namePool++}-${name.replace(/[\\/:\*\?"<>\|]/g, '')}`;
const file = URI.file(join(outputDir, `${fileName}.log`));
const appender = new OutputAppender(fileName, file.fsPath);
return new ExtHostOutputChannelBackedByFile(name, appender, this._proxy);
} catch (error) {
// Do not crash if logger cannot be created
this.logService.error(error);
return new ExtHostPushOutputChannel(name, this._proxy);
}
}

I do not know of other places where we create exthost output channel dir.

It would be great to get the stack trace to see where this error is coming from, otherwise it seems I am helpless.

sandy081 added a commit that referenced this issue Sep 23, 2020
@sandy081
Copy link
Member

Not sure if it helps but I simplified line 88 and broke it down.

@connor4312
Copy link
Member

connor4312 commented Sep 23, 2020

Yea that code looks just fine 🤔

I think in the next release for extensionhost debugging I will probably add everything outside the cwd to skipFiles anyway. That would wallpaper over this and also let people use "All Exceptions" / "Caught Exceptions" breakpoints without breaking in all their other extensions or internal code.

@connor4312 connor4312 self-assigned this Sep 23, 2020
@sandy081
Copy link
Member

Makes sense.

Let me know if there is anything to be done from my side?

@mikecentola
Copy link

Sorry I created a duplicate issue. Having this same issue on 1.50.0 on windows.

digeff pushed a commit to microsoft/vscode-js-debug that referenced this issue Nov 9, 2020
@roblourens roblourens added the verified Verification succeeded label Dec 3, 2020
@roblourens
Copy link
Member

Looks fine, but it looks like this was hard to repro, so someone who was seeing this, please try to verify that it's fixed in VS Code Insiders.

@github-actions github-actions bot locked and limited conversation to collaborators Dec 17, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug debug Debug viewlet, configurations, breakpoints, adapter issues verified Verification succeeded
Projects
None yet
Development

No branches or pull requests