google-cloud-node: `@google-cloud/tasks` 4.1.0 causes cloud_tasks_client_config.json `no such file or directory` (publish esm)

The following error happens with @google-cloud/tasks after updating from 4.0.1 to 4.1.0:

Error: ENOENT: no such file or directory, open '/vercel/path0/fuu/node_modules/.pnpm/@google-cloud+tasks@4.1.0_encoding@0.1.13/node_modules/@google-cloud/tasks/build/esm/src/v2/cloud_tasks_client_config.json'
    at Object.openSync (node:fs:603:3)
    at Object.readFileSync (node:fs:471:35)
    at 64300 (/var/task/fuu/.next/server/app/app/api/site/route.js:1:1998)
    at t (/var/task/fuu/.next/server/webpack-runtime.js:1:143)
    at __webpack_exec__ (/var/task/fuu/.next/server/app/app/api/route.js:57:72254)
    at /var/task/fuu/.next/server/app/app/api/route.js:57:72374
    at t.X (/var/task/fuu/.next/server/webpack-runtime.js:1:1285)
    at /var/task/fuu/.next/server/app/app/api/route.js:57:72340
    at Object.<anonymous> (/var/task/fuu/.next/server/app/app/api/route.js:57:72435)
    at Module._compile (node:internal/modules/cjs/loader:1256:14) {
  errno: -2,
  syscall: 'open',
  code: 'ENOENT',
  path: '/vercel/path0/fuu/node_modules/.pnpm/@google-cloud+tasks@4.1.0_encoding@0.1.13/node_modules/@google-cloud/tasks/build/esm/src/v2/cloud_tasks_client_config.json',
  page: '/app/api/sync'
}

This seems to be related to the only change with was made from from version 4.0.1 to version 4.1.0: https://github.com/googleapis/google-cloud-node/pull/4720

Environment details

  • which product (packages/*): @google-cloud/tasks
  • Node.js version: 18
  • npm version: pnpm

Steps to reproduce

About this issue

  • Original URL
  • State: open
  • Created 7 months ago
  • Reactions: 5
  • Comments: 22 (8 by maintainers)

Most upvoted comments

Having this issue after migration to 5.0 Reverting back to forced 4.0.1 fixes the issue

Thanks @sofisl - unfortunately the issue persists with 5.1.1 (including following the instructions above with your reproduction repo)

Hey @sofisl ,

import { CloudTasksClient } from "@google-cloud/tasks"

The application is a Next.js application. The package manager is pnpm and the build command next build.

Thanks @sofisl - to reproduce this issue in your example repo, we need to create a standalone build - this is what activates tracing in an attempt to create the minimum required build rather than including every file within node_modules

I’ve reproduced with your repo as follows:

  1. add output: standalone to next.config.mjs:
--- a/next.config.mjs
+++ b/next.config.mjs
@@ -1,5 +1,6 @@
 /** @type {import('next').NextConfig} */
 const nextConfig = {
+  output: "standalone",
   reactStrictMode: true,
 };
  1. generate the standalone build: npx next build

  2. run the standalone build: node .next/standalone/server.js

  3. open the index page in browser and observe the error in the server console output: Error: ENOENT: no such file or directory, open '[...]/debug-tasks-next.js/.next/standalone/node_modules/@google-cloud/tasks/build/esm/src/v2/cloud_tasks_client_config.json'

  4. additionally observe that Next.js successfully traces and copies the JSON file under the cjs build to .next/standalone/node_modules/@google-cloud/tasks/build/cjs/src/v2/cloud_tasks_client_config.json - but then imports from the esm folder, which lacks the json file.

You’ll see in the Next.js docs linked above that Next.js apparently supports manual inclusion of incorrectly omitted files; I haven’t managed to get this working (didn’t try super hard) but it may be a viable workaround, albeit Next.js-specific.

Thanks, hope this helps your investigation!

Closed this because at the time, the release was accidental, it should have been released as a breaking change. Reopening because it seems like it’s still an issue with the 5.0.0 release.

As a workaround, I’ve republished the ‘latest’ tag as 4.0.1. This should have been released as a breaking change. Please re-install the package at latest, it should work.