Skip to content

Impossible modularization of scheduled reducers due to dependency circularity #4899

@rubnfelix

Description

@rubnfelix

I'm attempting to implement a server tick to sync player intents and got stuck when implementing the schedule tables. This is probably a known issue but I'm wondering if there are any solutions I'm not aware of.

  • Schedule tables require ReducerExport objects as an argument's property.
  • Producing ReducerExport objects require a Schema object.
  • Scheduled reducers also expect the schedule table's rowType property as an argument's property.
  • Inserting to a schedule table requires the schedule table to be passed as an argument's property.

This whole situation forces both the schedule table, its reducer and the schema object to be declared within the same file otherwise initializing the projects results in

Publishing...
Publishing module ~\... to database 'db'
[CIRCULAR_DEPENDENCY] Warning: Circular dependency: ~/.../schema.ts -> ~/.../serverTick.ts -> ~/.../schema.ts.

Build finished successfully.
Uploading to local => http://127.0.0.1:3000
Checking for breaking changes...
Error: Pre-publish check failed with status 500 Internal Server Error: Uncaught ReferenceError: Cannot access 'spacetimedb' before initialization

Is there a way of making this work while preserving the folder structure?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions