Skip to content

fix(actor): adapt PlatformEventManager to crawlee v4 EventManager API#594

Open
B4nan wants to merge 5 commits intorefactor/configuration-class-redesignfrom
fix/event-manager-v4-adapt
Open

fix(actor): adapt PlatformEventManager to crawlee v4 EventManager API#594
B4nan wants to merge 5 commits intorefactor/configuration-class-redesignfrom
fix/event-manager-v4-adapt

Conversation

@B4nan
Copy link
Copy Markdown
Member

@B4nan B4nan commented Apr 30, 2026

Summary

Crawlee v4's EventManager constructor changed:

  • Now requires EventManagerOptions (just persistStateIntervalMillis).
  • Base class no longer carries a config field — the previous override readonly config pattern is invalid.

This PR adapts PlatformEventManager:

  • Drops the override; stores config as own readonly property.
  • Forwards persistStateIntervalMillis to super().
  • Adds a fromConfig() factory mirroring LocalEventManager.fromConfig() so the SDK plays nicely with the new ServiceLocator init path.

Stacking

Depends on #583 (config redesign). Rebases cleanly onto v4 once #583 lands.

B4nan added 5 commits April 30, 2026 21:13
Crawlee v4's `EventManager` constructor now requires
`EventManagerOptions` (just `persistStateIntervalMillis`), and the
base class no longer carries a `config` field — the previous
`override readonly config` pattern is no longer valid.

- Drop the `override` and store `config` as own readonly property.
- Forward `persistStateIntervalMillis` to `super()`.
- Add a `fromConfig()` factory mirroring `LocalEventManager.fromConfig()`
  so the SDK plays nicely with the new ServiceLocator-driven init path.

Stacked on #583 (config redesign); rebases onto v4 once that lands.
`Configuration.useEventManager()` was removed in crawlee v4. Install
the platform event manager via the global service locator instead, and
reset between tests so each case can register a fresh manager without
hitting `ServiceConflictError`.
Crawlee v4's `Configuration` is eager — `actorEventsWsUrl` is read
once at construction, so a global config that pre-existed the
`beforeEach` would never see the websocket URL we set, and
`events.init()` would silently never connect. Move the env-var setup
above `Configuration.getGlobalConfig()` and reset the SDK's static
singleton so each test rebuilds a fresh config.
@B4nan B4nan force-pushed the fix/event-manager-v4-adapt branch from 4f65fb8 to f5d0e03 Compare April 30, 2026 19:14
@B4nan B4nan changed the base branch from v4 to refactor/configuration-class-redesign May 6, 2026 09:26
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