Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JS] [Nextjs] googleCloud telemetry does not work due to bundling issues #937

Open
MichaelDoyle opened this issue Sep 19, 2024 · 0 comments
Assignees
Labels
bug Something isn't working js

Comments

@MichaelDoyle
Copy link
Member

MichaelDoyle commented Sep 19, 2024

Describe the bug

Init a new next.js project using the genkit CLI. Then add the googleCloud plugin and enable telemetry. google-proto-files are stripped by the bundler, unless explicitly externalized and/or required.

failed to create client: ENOENT: no such file or directory, open '/<REDACTED>/.next/google/devtools/cloudtrace/v2/tracing.proto'
{"stack":"Error: failed to create client: ENOENT: no such file or directory, open '/<REDACTED>/.next/google/devtools/cloudtrace/v2/tracing.proto'","message":"failed to create client: ENOENT: no such file or directory, open '/<REDACTED>/.next/google/devtools/cloudtrace/v2/tracing.proto'","errno":"-2","code":"ENOENT","syscall":"open","path":"/<REDACTED>/.next/google/devtools/cloudtrace/v2/tracing.proto","name":"Error"}

Resolution is to externalize this dependency and manually require it

nextjs.config.mjs

/** @type {import('next').NextConfig} */
const nextConfig = {
  experimental: {
    serverComponentsExternalPackages: [
      'google-proto-files',
    ],
  },
};

export default nextConfig;

genkit.ts

require('google-proto-files')

Runtime (please complete the following information):

Node: 20.17.0
Genkit: 0.5.13
Next: 14.2.12

** Node version**

v20.17.0

Additional context
This issue broadly applies to the use of bundlers. Issue was reported upstream GoogleCloudPlatform/opentelemetry-operations-js Issue 404 and a fix has been proposed, that we should track GoogleCloudPlatform/opentelemetry-operations-js PR 741.

@MichaelDoyle MichaelDoyle added bug Something isn't working js labels Sep 19, 2024
@MichaelDoyle MichaelDoyle self-assigned this Sep 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working js
Projects
None yet
Development

No branches or pull requests

1 participant