fix(langsmith): install workflow-bundle rewrites via compiler.webpack#2183
Merged
Conversation
ac0b122 to
7768d39
Compare
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.
7768d39 to
1cf75d3
Compare
chris-olszewski
approved these changes
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. |
Member
There was a problem hiding this comment.
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
Member
|
Would also be good to get a changelog entry for this |
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.
LangSmithPlugin.configureBundlerinstalls its Workflow-bundle rewrites (the langsmithnode:*→.browser.cjsredirects and aDefinePlugin) viarequire('webpack'). webpack is a dependency of@temporalio/worker, not of this plugin, so under a non-hoisting layout such as pnpmhoist=false, whichsamples-typescriptuses,requirethrowsMODULE_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.webpackinstead of importing it - nowebpackdependency, always the exact instance running the bundle, should work under anynode_moduleslayout.Verified by reproducing temporalio/samples-typescript#480 in isolation (pnpm
hoist=false, webpack 5.107.2, langsmith 0.7.17): fails onmain, compiles cleanly with this change.