temporalio / sdk-typescript

Temporal TypeScript SDK
Other
531 stars 104 forks source link

[Bug] Critical dependency: the request of a dependency is an expression #1489

Open shadiramadan opened 3 months ago

shadiramadan commented 3 months ago

What are you really trying to do?

I'm trying to build / run a Next.js application without any warnings or errors. I am only using the @temporalio/client to be able to Signal workflows.

Describe the bug

I have a server-only file that imports the client:

import { Client, Connection } from "@temporalio/client";

The client is used in some server side logic. When running next as a build or in dev mode (and loading a page that references the import). I get the following error:

./node_modules/.pnpm/@temporalio+common@1.10.3/node_modules/@temporalio/common/lib/internal-non-workflow/data-converter-helpers.js
Critical dependency: the request of a dependency is an expression

Import trace for requested module:
./node_modules/.pnpm/@temporalio+common@1.10.3/node_modules/@temporalio/common/lib/internal-non-workflow/data-converter-helpers.js
./node_modules/.pnpm/@temporalio+common@1.10.3/node_modules/@temporalio/common/lib/internal-non-workflow/index.js
./node_modules/.pnpm/@temporalio+client@1.10.3/node_modules/@temporalio/client/lib/async-completion-client.js
./node_modules/.pnpm/@temporalio+client@1.10.3/node_modules/@temporalio/client/lib/index.js
./src/lib/temporal.ts
./src/lib/auth/index.ts
./src/app/[locale]/layout.tsx

Minimal Reproduction

Load the temporal client on the server side.

Environment/Versions

OS: MacOS Sonoma 14.5 (23F79)
Package: "@temporalio/client": "^1.10.3",
Node: v20.16.0

Additional context

My signal workflow logic works fine. The error also occurs in a linux based docker image.

shadiramadan commented 3 months ago

Possibly related #1292

mjameswh commented 1 month ago

Possibly related 1292

That touches the same part of the code, but the use case is very different.

Implementing #1458 is certainly part of the solution, but I'm afraid that will not be enough to avoid the build error people are seeing when bundling the client.

shadiramadan commented 1 month ago

@mjameswh Do you know how to work around this error in the temporal client or is it unavoidable at this time?