Skip to content

CrawlerEvent is declared twice and the copies can silently disagree #251

Closed

Description

@nc9

CrawlerEvent is declared twice, and the two copies must be edited together or the change is silently useless.

  • packages/core-contracts/src/index.ts holds the copy every consumer outside the crawler package reads: the CLI's event switches and the hosted runtime.
  • packages/crawler/src/core/types.ts holds a second, hand-maintained union of named interfaces (CrawlerStartedEvent, CrawlerErrorEvent, and so on). That is the one core/crawler.ts imports and emits against.

Both failure directions are quiet in their own way:

  • Add a member to core-contracts only and the emit site fails with TS2322: Type '"warning"' is not assignable to …, printing a union that visibly lacks the member. It reads like a stale build or a cache problem, not a second declaration.
  • Add it to the crawler's copy only and everything compiles and runs, while the event is invisible to every external consumer, because they are narrowing against the other type.

Hit while adding the warning event in #249. The fix there was to update both and share CrawlWarningCode from core-contracts so at least the payload cannot drift, but the shape is still two sources of truth for one contract.

Acceptance Criteria

  • CrawlerEvent has exactly one declaration; the other location re-exports it rather than restating it
  • The named per-event interfaces the crawler uses internally (CrawlerPageUnchangedEvent and friends) still resolve for existing importers, or their importers are updated
  • Adding a member in one file and nowhere else either compiles everywhere or fails everywhere, never one and not the other
  • tsgo --noEmit clean for packages/crawler, packages/core-contracts and apps/cli
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3choresize: S

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions