-
Notifications
You must be signed in to change notification settings - Fork 53
improved cloudflare worker support #1274
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
base: main
Are you sure you want to change the base?
Conversation
b716030 to
8d2e5e2
Compare
…p to avoid removing the prefix
| import { _internalSetInitialState } from "./logger"; | ||
| import { promisify } from "util"; | ||
| import * as zlib from "zlib"; | ||
| import { renderNunjucksString as nunjucksRender } from "./template/nunjucks-env"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
something to consider for the future (or perhaps the ai is quick to do this).
i previously added a lint rule to disallow import from cli in the sdk/js.
what if we had a sdk/js/node and sdk/js/browser ... we then move files in two each of those. we could say that nothing is allowed to depend on sdk/js/node/** unless the it stems from node.ts, and same with browser.ts
|
okay I removed a couple of the dead files and removed the noExternal change I had made after we made the deno test changes. once smoke-v2 is merged in we can update the compatibility dates for the cloudflare tests. Update: discussed and we plan to keep the older compatibility dates for wrangler and the specific newer date that is required for vite+cloudflare plugin |
## Braintrust JS SDK Smoke Tests v2 ### Design Principles 1. **Well-Known Tarball Paths**: Uses version-agnostic paths like `braintrust-latest.tgz` so package.json never changes 2. **Build Before Install**: Ensures artifacts exist before npm tries to install them 3. **Track Lock Files**: Commits lock files to catch transitive dependency issues 4. **Makefile as Source of Truth**: Single clear interface (`make test`) for every scenario 5. **Expected Failures Support**: Uses `xfail` status to document known platform limitations without failing tests ### Quick Start ```bash # Run all scenarios make test # Run specific scenario make test otel-v1 # List available scenarios make list ``` ### What's Improved from v1 - ✅ No version-specific tarballs (eliminates package.json churn) - ✅ Peer dependencies fully specified (no `--legacy-peer-deps` workaround) - ✅ Auto-discovery (no manual registration) - ✅ Shared test package for DRY test logic - ✅ Lock files tracked (surfaces packaging issues early) This infrastructure ensures the Braintrust SDK "just works" across the JavaScript ecosystem's diverse runtime landscape.
| "@std/assert": "jsr:@std/assert@^1.0.14", | ||
| "@braintrust/smoke-test-shared": "jsr:@braintrust/smoke-test-shared", | ||
| "braintrust": "npm:braintrust@^2.0.2" | ||
| "braintrust": "npm:braintrust" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
avoid us having to update this
| cd ../../.. && pnpm exec turbo build --filter=braintrust; \ | ||
| fi; \ | ||
| fi | ||
| if [ -n "$(BRAINTRUST_TAR)" ]; then \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't care to rebuild lcoally. the tar is important for ci
| echo "==> Building SDK for workspace link"; \ | ||
| cd ../../.. && pnpm exec turbo build --filter=braintrust; \ | ||
| fi; \ | ||
| deno install |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deno install seems to ignore the links directive and tries to grab from npm.
This PR updates default entrypoint selection so each runtime resolves the correct build. Node environments select the Node entrypoint, while browser and worker environments default to the browser build. Worker runtimes no longer implicitly resolve the Node build. Importing braintrust/node must be done explicitly and is expected to fail in workers (e.g. cloudflare-vite-hono-vite-dev-node-esm), rather than failing due to accidental default resolution. PR changes: The change uses Node’s conditional exports to ensure the correct build is selected based on runtime capabilities, instead of relying on ambiguous defaults. Each scenario now checks that the appropriate isomorphic build type (Node vs browser) is selected and that module resolution lands on the correct output files for that environment.
Simpler testing/expecting and ensure all scenarios are running all the things. Currently CI shows failing because of ALS not working in /browser. Expected for now.
Problem
Cloudflare Workers are encountering compatibility issues with certain dependencies in the Braintrust SDK. These issues surface particularly in restrictive runtime environments and how some dependencies behave in Vite-based builds.
Changes
Maintain this existing build structure:
braintrust (CJS) -> node
braintrust (ESM) -> node
braintrust/browser -> no cli, no filesystem, no git, no nunjucks