Repository navigation
Conversation
…code The OTel SDK setup file was only loaded by the dev API server watcher, and via --require, which cannot load an ESM file using top-level await. A shared getOTelImportArgs() helper now preloads api/dist/opentelemetry.js with --import in the production API server (both the server-file path and the default server), the job workers, and the dev watcher. The default in-process server imports the setup file before Fastify and Prisma load. The setup command prints the flag to use under your own process manager.
…s serving The setup path is now returned as a file URL so Node resolves it as an ESM specifier on Windows too. The default API server and the both-sides in-process server import Fastify and the server factory after the setup file, so the Fastify instrumentation can still patch them. The bin entry loads the api handlers lazily for the same reason. cedar serve --ud imports the setup before the built Fetchable, cedar serve with a custom server file preloads it on the node process for both sides, and the setup command notice mentions the covered modes.
The lazy-handler change dropped the webHandler import, so cedarjs-server web crashed with a ReferenceError before parsing options.
✅ Deploy Preview for cedarjs canceled.
|
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (13)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
| { | ||
| name: 'api', | ||
| command: `${formatRunBinCommand('node', [path.join('dist', 'server.js'), '--apiPort', String(argv.apiPort), '--apiHost', argv.apiHost, '--apiRootPath', apiRootPath])}`, | ||
| command: `${formatRunBinCommand('node', [...getOTelImportArgs(), path.join('dist', 'server.js'), '--apiPort', String(argv.apiPort), '--apiHost', argv.apiHost, '--apiRootPath', apiRootPath])}`, |
There was a problem hiding this comment.
Project paths break server startup
If the project directory contains shell characters, such as /srv/cedar&demo, cedar serve with OpenTelemetry enabled and a custom server now fails to start the API. The new absolute file URL goes into an unquoted shell command. The & remains in the URL, so the shell splits the command instead of passing the complete --import argument to Node.
Quote the preload argument for the shell, or launch Node with an argument array.
| title: 'Notice: running under your own process manager...', | ||
| task: (_ctx: unknown, task: { output: string }) => { | ||
| task.output = [ | ||
| 'The setup file is loaded automatically by `cedar dev` (including `--ud`), `cedar serve api`, `cedar serve`, `cedarjs-server api` and the job workers.', |
There was a problem hiding this comment.
Unified dev notice promises traces
The new notice says cedar dev --ud loads the setup automatically, but that command starts cedar-unified-dev, which does not import the setup. Its OpenTelemetry code only adds tracing calls to API source files; it does not register a provider or exporter. Users following this guidance can expect traces that never get exported.
Remove the --ud claim until that startup path loads the setup.
| 'The setup file is loaded automatically by `cedar dev` (including `--ud`), `cedar serve api`, `cedar serve`, `cedarjs-server api` and the job workers.', | |
| 'The setup file is loaded automatically by `cedar dev` without `--ud`, `cedar serve api`, `cedar serve`, `cedarjs-server api` and the job workers.', |
| const configPath = path.join(FIXTURE_BASEDIR, 'redwood.toml') | ||
| const originalConfig = fs.readFileSync(configPath, 'utf-8') | ||
| try { | ||
| fs.writeFileSync( | ||
| configPath, | ||
| originalConfig.concat( | ||
| '\n[experimental.opentelemetry]\n\tenabled = true\n\twrapApi = true\n', | ||
| ), | ||
| ) |
There was a problem hiding this comment.
Tests change shared fixture files
These tests rewrite the shared empty-project/redwood.toml and remove the entire api/dist directory during cleanup. Other test files read this fixture, and the test configuration allows parallel files. Readers can therefore see the configuration while it is being rewritten, and future tests that add build files can have those files deleted.
Use a private temporary project, or mock configuration and file checks.
Fixes #2861
The OTel SDK setup file was only ever loaded by the dev API server watcher, and via
--require, which cannot load an ESM file that uses top-level await.A shared
getOTelImportArgs()helper in@cedarjs/project-configresolves the builtapi/dist/opentelemetry.jsand returns a--import=<path>entry. It is now used by:api-server-watch) — replacing the inline--requirelogiccedarjs-server api,cedar serve api)cedar jobs work|startforks)await import()s the setup file before Fastify, Prisma and the app's own modules loadThe setup command now prints the flag to use when running under your own process manager.
Opened from a branch in this repo so the full CI suite runs. Original PR by @niukanen1: #2887