fix(workspace): guard downloadAndSave against non-browser environments#247
Open
VascoSch92 wants to merge 1 commit into
Open
fix(workspace): guard downloadAndSave against non-browser environments#247VascoSch92 wants to merge 1 commit into
VascoSch92 wants to merge 1 commit into
Conversation
RemoteWorkspace.downloadAndSave() uses browser-only DOM APIs (document.createElement, document.body, URL.createObjectURL). In a Node.js environment these throw a cryptic "ReferenceError: document is not defined". Add a runtime guard that throws a clear, actionable error pointing Node.js callers to downloadAsBlob() / downloadAsText() instead. Browser behavior is unchanged. Closes #114
Contributor
Endpoint audit❌ 7 off-contract call(s) — not on the agent-server · classifiers: cloud
❌ Not on agent-server (gated, 7)⛔ (no known backend) — served by no backend we can see (6)
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
RemoteWorkspace.downloadAndSave()uses browser-only DOM APIs (document.createElement,document.body,URL.createObjectURL) with no environment check. In Node.js — a common environment forRemoteWorkspaceautomation — it throws a crypticReferenceError: document is not defined.Closes #114.
Change
Add a runtime guard at the top of
downloadAndSave():ReferenceError. The suggested fallbacks (downloadAsBlob(),downloadAsText()) already exist and are Node-safe.Tests
New
src/__tests__/remote-workspace-download.test.ts:testEnvironment: 'node') suite and confirms the network is never touched;document/URL, the anchor download still fires (createElement('a'),href,click,appendChild/removeChild,revokeObjectURL);saveAsFileName.Full unit suite green (274 tests),
tscbuild clean, eslint + prettier clean.