Skip to content

InitialData breaks SSR #381

@thebuilder

Description

@thebuilder

Trying to render an application with some initialData, which triggers some async calls.

if (query.state.data) {
   query.scheduleStaleTimeout(); // Simulate a query healing process

    query.heal(); // Schedule for garbage collection in case
    // nothing subscribes to this query

    query.scheduleGarbageCollection();
}

The scheduleStaleTimeout() and scheduleGarbageCollection() can be prevented from running by setting stale and cache to Infinity, but heal() will always call a clearTimeout function.

In our server environment calling setTimeout or clearTimeout throws an error.

The fix is to add the isServer check to the if statement - I'm just not sure if there's any consequences to doing this? Does the server actually need to call any of these methods?

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