Skip to content

How to read from filesystem in worker in web extension? #1535

Discussion options

You must be logged in to vote

Can we somehow access vscode.workspace.fs in such a worker?

No. browserServerMain.js is executed in the context of Web Worker. The vscode module is not provided in the context.

	const serverMain = Uri.joinPath(context.extensionUri, 'server/dist/browserServerMain.js');
	const worker = new Worker(serverMain.toString(true));

https://github.com/microsoft/vscode-extension-samples/blob/a11599ca990d239073f4b9978723800d8565d9fb/lsp-web-extension-sample/client/src/browserClientMain.ts#L44-L45

However, even in the context of Web Worker, you can execute fetch('file:///localworkspacedir/local/file') if you want.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@Viir
Comment options

@tamuratak
Comment options

@Viir
Comment options

@tamuratak
Comment options

Answer selected by isidorn
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants