Skip to content

False positive pushstate warnings #11671

@dummdidumm

Description

@dummdidumm
          This PR, released as part of `v2.3.4` results in a new warning that wasn't previously there:
[Warning] Avoid using `history.pushState(...)` and `history.replaceState(...)` as these will conflict with SvelteKit's router. Use the `pushState` and `replaceState` imports from `$app/navigation` instead. (client.js, line 2580)

I'm not using history as suggested by the warning. I'm using goto in a couple of places, from $app/navigation. I haven't changed anything. The warning is not present with v2.3.3.

From a quick test, commenting out all the goto calls still resulted in the warning.

Originally posted by @lukasmalkmus in #11657 (comment)

I think this happens because when a library like Google Analytics monkey patches pushstate it will be next in the call stack, resulting in the false positive. I'm not sure how to solve this other than checking the whole stack for an occurrence of the client file, which may result in false negatives.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions