Skip to content

Pinia is not injected before vue-router beforeEach #1436

Closed
@BenShelton

Description

@BenShelton

Reproduction

https://stackblitz.com/edit/github-ddb6tb?file=src/main.ts

Steps to reproduce the bug

  1. Install Pinia & Vue Router
  2. Add a beforeEach on the router instance that uses a store
  3. Check console on startup

Expected behavior

No warnings appear

Actual behavior

Warning about injection symbol appears. See screenshot (the toRefs warning appears unrelated):

Screenshot 2022-07-08 at 14 42 02

Additional information

This is a minimal example of what we have already had running for a long time in production. Since upgrading to Vue 2.7 this warning has started to appear with no other code changes.

Workaround is adding an await nextTick() in the start of the router guard which makes the error disappear.

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