Skip to content

⚡️ rebuild worker only when needed#4170

Open
BenoitZugmeyer wants to merge 1 commit intomainfrom
benoit/speed-up-build
Open

⚡️ rebuild worker only when needed#4170
BenoitZugmeyer wants to merge 1 commit intomainfrom
benoit/speed-up-build

Conversation

@BenoitZugmeyer
Copy link
Member

@BenoitZugmeyer BenoitZugmeyer commented Feb 12, 2026

Motivation

Build is unnecessary slow because we rebuild the worker unnecessarily most of the time.

Changes

Before

yarn build:bundle  6.001s
yarn test:unit --spec packages/rum/src/domain/deflate/deflateWorker.spec.ts  5.808s

After

yarn build:bundle  4.546s
yarn test:unit --spec packages/rum/src/domain/deflate/deflateWorker.spec.ts 3.751s

Test instructions

Tests should cover this change, however you can try the commands above

Checklist

  • Tested locally
  • Tested on staging
  • Added unit tests for this change.
  • Added e2e/integration tests for this change.
  • Updated documentation and/or relevant AGENTS.md file

@BenoitZugmeyer BenoitZugmeyer marked this pull request as ready for review February 12, 2026 16:42
@BenoitZugmeyer BenoitZugmeyer requested a review from a team as a code owner February 12, 2026 16:42
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6a5f9cb9ea

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


const bundleMtime = fs.statSync(bundlePath).mtimeMs

return fs.globSync('src/**/*', { cwd: WORKER_PATH }).some((file) => {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Rebuild worker when non-src inputs change

needsWorkerRebuild() only compares bundle/worker.js against files under packages/worker/src, but the worker bundle also depends on inputs outside that tree (for example @datadog/browser-core imported in packages/worker/src/boot/startWorker.ts via tsconfig path aliases, and webpack settings used by scripts/build/build-package.ts). After changing those external inputs, this check can incorrectly skip rebuilding and WORKER_STRING will embed stale worker code in RUM builds/tests until someone manually rebuilds or deletes the bundle.

Useful? React with 👍 / 👎.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True but the function imparted in startWorker.ts is minimal, it should be fine.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this will also only happen in local environment. In the CI it will always be build, so we don't risk shipping stale worker in a release.


const bundleMtime = fs.statSync(bundlePath).mtimeMs

return fs.globSync('src/**/*', { cwd: WORKER_PATH }).some((file) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this will also only happen in local environment. In the CI it will always be build, so we don't risk shipping stale worker in a release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants