{"record":{"id":"94a2513e26e1ab8b","repo":"pydantic/monty","slug":"the-wasm-worker-does-not-support-filesystem-mounts-browser","errorCode":null,"errorMessage":"the wasm worker does not support filesystem mounts (browser has no host filesystem)","messagePattern":"the wasm worker does not support filesystem mounts \\(browser has no host filesystem\\)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"crates/monty-js/ts/worker/transport.ts","lineNumber":134,"sourceCode":"            : { printFlushIntervalMs: flushIntervalMs(config.printFlushInterval) }),\n        },\n      },\n      'ok',\n      'Configure',\n    )\n    return transport\n  }\n\n  /** Feeds one snippet and eagerly converts its named inputs. */\n  feed(\n    code: string,\n    inputs: Record<string, unknown> | null,\n    mounts: readonly unknown[],\n    options: { cwd?: string; skipTypeCheck: boolean },\n    onPrint: OnPrint,\n  ): Promise<NativeTurn> {\n    if (mounts.length > 0) {\n      throw new Error('the wasm worker does not support filesystem mounts (browser has no host filesystem)')\n    }\n    const cwd = feedCwd(options.cwd)\n    if (typeof cwd !== 'string') {\n      return Promise.resolve(cwd)\n    }\n    return this.turn(\n      {\n        tag: 'feed',\n        val: {\n          code,\n          inputs: Object.entries(inputs ?? {}).map(([name, value]) => ({ name, value: encodeValue(value) })),\n          skipTypeCheck: options.skipTypeCheck,\n          cwd,\n        },\n      },\n      onPrint,\n    )\n  }","sourceCodeStart":116,"sourceCodeEnd":152,"githubUrl":"https://github.com/pydantic/monty/blob/adc986b362e3961f407868cb118a99fe831b9e61/crates/monty-js/ts/worker/transport.ts#L116-L152","documentation":"The wasm worker runs inside a browser Web Worker (or an in-process degrade) where there is no host filesystem, so `feedRun`/`feed` cannot honor `MountDir` mounts. If the request includes any mounts, the transport throws immediately rather than silently dropping them. Mounts are only available on the native napi/subprocess path.","triggerScenarios":"Calling `session.feedRun(code, { mounts: [...] })` (or `feed(...)`) with a non-empty `mounts` array on a session obtained from `createWorkerPool` / the wasm `Monty` entry point.","commonSituations":"Sharing one code path between native (`@pydantic/monty` napi) and browser deployments where the native path accepts mounts; porting server code that uses `MountDir` to the browser; forgetting that `@pydantic/monty/wasm` is the browser-targeted subpath.","solutions":["Remove the `mounts` argument (pass an empty array) when targeting the wasm worker.","Move file-dependent work to the host: read files in JS before the run and inject their contents via `inputs` instead of mounting directories.","If filesystem mounts are required, use the native napi pool (`Monty.create()` from the package root) which runs workers via the `monty` binary with a real `MountTable`.","Branch on environment capability at startup and choose the native vs wasm pool accordingly."],"exampleFix":"// before\nconst session = await pool.checkout()\nawait session.feedRun(code, { mounts: [new MountDir('/data', './data')] }) // throws on wasm\n\n// after\nconst session = await pool.checkout()\nconst data = await readFileText('./data/input.txt') // host-side read\nawait session.feedRun(code, { inputs: { data } })","handlingStrategy":"validation","validationCode":"if (mounts.length > 0 && isWasmPool(pool)) {\n  throw new Error('strip mounts before feeding a wasm-backed session')\n}","typeGuard":"function supportsMounts(pool: WorkerPool): boolean {\n  return !isWasmPool(pool) // native napi pools support MountDir\n}","tryCatchPattern":"try {\n  await session.feedRun(code, { mounts })\n} catch (err) {\n  if (err instanceof Error && err.message.includes('does not support filesystem mounts')) {\n    await session.feedRun(code, { inputs: await readHostFiles() })\n  } else throw err\n}","preventionTips":["Keep mount usage behind a native-only code path.","Inject file contents via `inputs` instead of MountDir in browser builds.","Branch pool selection on environment capability at startup.","Document to consumers that wasm sessions cannot mount host directories."],"tags":["wasm","browser","filesystem","wasm-worker"],"backgroundTag":"unsupported-operation","analyzedSha":"adc986b362e3961f407868cb118a99fe831b9e61","analyzedAt":"2026-09-13T19:19:18.698Z","contentChangedAt":"2026-09-13T19:19:18.698Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}