Skip to content

fix(langsmith): install workflow-bundle rewrites via compiler.webpack#2183

Merged
xumaple merged 1 commit into
mainfrom
dabh/langsmith-webpack-resolution
Jul 9, 2026
Merged

fix(langsmith): install workflow-bundle rewrites via compiler.webpack#2183
xumaple merged 1 commit into
mainfrom
dabh/langsmith-webpack-resolution

Conversation

@DABH

@DABH DABH commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

LangSmithPlugin.configureBundler installs its Workflow-bundle rewrites (the langsmith node:*.browser.cjs redirects and a DefinePlugin) via require('webpack'). webpack is a dependency of @temporalio/worker, not of this plugin, so under a non-hoisting layout such as pnpm hoist=false, which samples-typescript uses, require throws MODULE_NOT_FOUND, which the helpers silently swallow. See initial CI failures in temporalio/samples-typescript#480.

This fix installs the rewrites from a single plugin that reads webpack off compiler.webpack instead of importing it - no webpack dependency, always the exact instance running the bundle, should work under any node_modules layout.

Verified by reproducing temporalio/samples-typescript#480 in isolation (pnpm hoist=false, webpack 5.107.2, langsmith 0.7.17): fails on main, compiles cleanly with this change.

@DABH DABH requested a review from a team as a code owner July 9, 2026 00:24
@DABH DABH force-pushed the dabh/langsmith-webpack-resolution branch from ac0b122 to 7768d39 Compare July 9, 2026 00:26
LangSmithPlugin.configureBundler installs three webpack rewrites into the
Workflow bundle (node:async_hooks -> isolate shim, langsmith node-only
utils/{fs,worker_threads}.cjs -> .browser.cjs, and a config DefinePlugin),
acquiring webpack via require('webpack').

webpack is a dependency of @temporalio/worker, not of this plugin, so the
bare require only resolves when webpack is hoisted (npm, yarn, default pnpm).
Under a non-hoisting layout -- notably pnpm with hoist=false, which
samples-typescript uses -- it throws MODULE_NOT_FOUND, which the helpers
silently swallowed. The rewrites were skipped, langsmith's Node-only fs.cjs
stayed in the isolate bundle, and the build failed far downstream with an
opaque UnhandledSchemeError on node:fs/fs-promises/path/worker_threads
(temporalio/samples-typescript#480).

Install the rewrites from a single plugin whose apply() reads webpack off
`compiler.webpack` instead of importing it. This needs no webpack dependency,
works regardless of the consumer's node_modules layout, and uses the exact
webpack instance running the bundle -- never a second copy.
@DABH DABH force-pushed the dabh/langsmith-webpack-resolution branch from 7768d39 to 1cf75d3 Compare July 9, 2026 00:37
@DABH DABH changed the title fix(langsmith): resolve webpack via @temporalio/worker for workflow bundle rewrites fix(langsmith): install workflow-bundle rewrites via compiler.webpack Jul 9, 2026
* so a user's own `fs.cjs` is never rewritten.
* A webpack plugin that installs the three Workflow-bundle rewrites LangSmith needs:
*
* - redirect `node:async_hooks` to the isolate-safe workflow-interceptor shim.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outside of the scope of this PR, but it might be worthwhile to look into the AsyncLocalStorage we provide that is hooked up to workflow lifecycle instead of handrolling a shim: https://github.com/temporalio/sdk-typescript/blob/main/packages/worker/src/workflow/vm-shared.ts#L156

@chris-olszewski

Copy link
Copy Markdown
Member

Would also be good to get a changelog entry for this

@xumaple xumaple merged commit 0c62240 into main Jul 9, 2026
100 of 107 checks passed
@xumaple xumaple deleted the dabh/langsmith-webpack-resolution branch July 9, 2026 18:15
chris-olszewski pushed a commit that referenced this pull request Jul 13, 2026
…#2183) (#2189)

Co-authored-by: David Hyde <DABH@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

3 participants