Skip to content

Fix custom element WorkerService to match init() refactor#641

Open
zhaoyuheng200 wants to merge 2 commits into
google-ai-edge:mainfrom
zhaoyuheng200:fix/custom-element-worker-init
Open

Fix custom element WorkerService to match init() refactor#641
zhaoyuheng200 wants to merge 2 commits into
google-ai-edge:mainfrom
zhaoyuheng200:fix/custom-element-worker-init

Conversation

@zhaoyuheng200

@zhaoyuheng200 zhaoyuheng200 commented May 16, 2026

Copy link
Copy Markdown
Contributor

Summary

  • The custom_element/worker_service.ts (used via fileReplacements in angular.json during the custom_element build) was not updated when 49aa6a8 refactored WorkerService to use a lazy init() method instead of constructor initialization.
  • This causes ng build custom_element to fail with TS2339: Property 'init' does not exist on type 'WorkerService', which blocks npm package builds.

Test plan

  • Run ng build custom_element — should succeed without TS errors
  • Run npm run build-npm — should produce the full npm package in custom_element_npm/dist/

The custom_element/worker_service.ts (used as a fileReplacement during
the custom_element build) was not updated when 49aa6a8 refactored
WorkerService to use a lazy init() method instead of constructor
initialization. This breaks `ng build custom_element`.
@sealuck

sealuck commented Jul 11, 2026

Copy link
Copy Markdown

Confirmed this still reproduces on current upstream main at 202934b5caaa057f7150240e22d613214cb8c543:

TS2339: Property init does not exist on type WorkerService.
src/components/visualizer/app_service.ts:1114

I reproduced it with npx ng build custom_element in a clean worktree. Applying this PR lifecycle-compatible implementation makes the custom-element production build succeed. The init() recreation is also important when an existing visualizer receives a new graphCollections input, because setupWorker() registers a new message listener on each reinitialization.

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