unjs / unhead

Unhead is the any-framework document head manager built for performance and delightful developer experience.
https://unhead.unjs.io
MIT License
549 stars 36 forks source link

nuxt 3 with keep alive app #141

Open userquin opened 1 year ago

userquin commented 1 year ago

Environment

Nuxt 3.3.2, Node 16.17.0 (on my local), can use Node 18: check package on Elk repo https://github.com/elk-zone/elk

Reproduction

check https://github.com/elk-zone/elk/issues/1776, we can use https://elk.main, requires mastodon account, check video on Additional context.

Describe the bug

There is no way to correlate head data and current route: when we use keep alive, all headers configured on any page that has been activated will be there.

It seems we've a race condition with deactivated and activated page hooks, check snippet code on Additional context below.

Additional context

You can check it in this video: https://streamable.com/e1jmkr

Using this code on plugins/hydration.client.ts, active header entries grows and grows on each transition:

import { getActiveHead } from 'unhead'

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.hooks.hookOnce('app:suspense:resolve', () => {
    isHydrated.value = true
  })
  if (!process.server) {
    nuxtApp.hooks.hook('page:finish', async () => {
      console.log(getActiveHead()?.headEntries())
    })
  }
})

Logs

No response

userquin commented 1 year ago

I guess, a simple fix for vue will be to return undefined in the watchEffect when deactivated, and do not patch the entry if undefined in the watcher: https://github.com/unjs/unhead/blob/main/packages/vue/src/runtime/composables/util/clientUseHead.ts#L13

userquin commented 1 year ago

There is no way to build unhead on Windows using Node 16.17, dom package error:

build error ```shell packages/dom build$ unbuild . │ i Building @unhead/dom │ Error building D:/work/projects/userquin/GitHub/userquin/unjs/unhead/packages/dom: SyntaxError: Unexpected token (1:5) in D:\work\projects\userquin\GitHub\userquin\unjs\unhead\ │ SyntaxError: Unexpected token (1:5) in D:\work\projects\userquin\GitHub\userquin\unjs\unhead\node_modules\.pnpm\zhead@2.0.4\node_modules\zhead\dist\index.d.ts │ at Object.pp$4.raise (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:20805: │ at Object.pp$9.unexpected (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:1 │ at Object.pp$9.semicolon (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:18 │ at Object.pp$8.parseExpressionStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/n │ at Object.pp$8.parseStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry. │ at Object.pp$8.parseTopLevel (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.j │ at Object.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17935:15) [1 lines collapsed] packages/ssr build$ unbuild . │ i Building @unhead/ssr │ √ Build succeeded for ssr │ dist/index.cjs (size: 3.17 kB, exports: encodeInnerHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString) │ dist/index.mjs (size: 3.07 kB, exports: encodeInnerHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString) │ Σ Total dist size (byte size): 6.91 kB └─ Running... │ at Function.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17985:35) └2 Running... │ SyntaxError: Unexpected token (1:5) in D:\work\projects\userquin\GitHub\userquin\unjs\unhead\node_modules\.pnpm\zhead@2.0.4\node_modules\zhead\dist\index.d.ts │ at Object.pp$4.raise (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:20805: │3 at Object.pp$9.unexpected (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:1 │ at Object.pp$4.raise (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:20805: │ at Object.pp$9.unexpected (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:1 │4 at Object.pp$9.semicolon (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:18 │ at Object.pp$9.unexpected (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:1 │ at Object.pp$9.semicolon (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:18 │5 at Object.pp$8.parseExpressionStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/n │ at Object.pp$9.semicolon (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:18 │ at Object.pp$8.parseExpressionStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/n │6 at Object.pp$8.parseStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry. │ at Object.pp$8.parseExpressionStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/n │ at Object.pp$8.parseStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry. │7 at Object.pp$8.parseTopLevel (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.j │ at Object.pp$8.parseStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry. │ at Object.pp$8.parseTopLevel (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.j │8 at Object.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17935:15) │ at Object.pp$8.parseTopLevel (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.j │ at Object.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17935:15) │9 at Function.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17985:35) │ at Object.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17935:15) │ at Function.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17985:35) [10 lines collapsed]xtParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:24381 │ at Function.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17985:35) │ at Graph.contextParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:24381 │ 1 at tryParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/@rollup+plugin-commonjs@24.0.1_rollup@3.17.3/node_modules/@rollup/plugin-commo │ at Graph.contextParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:24381 │ at tryParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/@rollup+plugin-commonjs@24.0.1_rollup@3.17.3/node_modules/@rollup/plugin-commo │ 2 pos: 5, │ at tryParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/@rollup+plugin-commonjs@24.0.1_rollup@3.17.3/node_modules/@rollup/plugin-commo │ pos: 5, │ 3 loc: { │ pos: 5, │ loc: { │ 4 column: 5, │ loc: { │ column: 5, │ 5 file: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ column: 5, │ file: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ 6 line: 1 │ file: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ line: 1 │ 7 }, │ line: 1 │ }, │ 8 raisedAt: 16,n' + │ }, │ raisedAt: 16,n' + │ 9 frame: "1: type Booleanable = boolean | 'false' | 'true' | '';\n" +node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ raisedAt: 16,n' + │ frame: "1: type Booleanable = boolean | 'false' | 'true' | '';\n" +node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │20 ' ^\n' + │ frame: "1: type Booleanable = boolean | 'false' | 'true' | '';\n" +node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ ' ^\n' + │ 1 '2: type Stringable = string | Booleanable | number;\n' +unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ ' ^\n' + │ '2: type Stringable = string | Booleanable | number;\n' +unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ 2 '3: type Arrayable = T | Array;', │ '2: type Stringable = string | Booleanable | number;\n' +unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ '3: type Arrayable = T | Array;', │ 3 id: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ '3: type Arrayable = T | Array;', │ id: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ 4 hook: 'resolveId', │ id: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ hook: 'resolveId', │ 5 code: 'PLUGIN_ERROR', │ hook: 'resolveId', │ code: 'PLUGIN_ERROR', │ 6 plugin: 'commonjs--resolver',in\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts',EntryUpdatesPlugin.ts', │ code: 'PLUGIN_ERROR', │ plugin: 'commonjs--resolver',in\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts',EntryUpdatesPlugin.ts', │ 7 watchFiles: [ │ plugin: 'commonjs--resolver',in\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts',EntryUpdatesPlugin.ts', │ watchFiles: [ │ 8 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts',EntryUpdatesPlugin.ts', │ watchFiles: [ │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts',EntryUpdatesPlugin.ts', │ 9 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\renderDOMHead.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts',EntryUpdatesPlugin.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\renderDOMHead.ts', │30 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\patchDomOnEntryUpdatesPlugin.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\renderDOMHead.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\patchDomOnEntryUpdatesPlugin.ts', │ 1 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\setAttrs.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\patchDomOnEntryUpdatesPlugin.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\setAttrs.ts', │ 2 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\hash.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\setAttrs.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\hash.ts', │ 3 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\index.ts',.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\hash.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\index.ts',.ts', │ 4 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\schema.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\index.ts',.ts',_modules\\zhead\\dist\\index.d.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\schema.ts', │ i Building @unhead/doms\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\safeSchema.ts',_modules\\zhead\\dist\\index.d.ts', │ Error building D:/work/projects/userquin/GitHub/userquin/unjs/unhead/packages/dom: SyntaxError: Unexpected token (1:5) in D:\work\projects\userquin\GitHub\userquin\unjs\unhead\ │ SyntaxError: Unexpected token (1:5) in D:\work\projects\userquin\GitHub\userquin\unjs\unhead\node_modules\.pnpm\zhead@2.0.4\node_modules\zhead\dist\index.d.ts │ at Object.pp$4.raise (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:20805: │ at Object.pp$9.unexpected (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:1 │ at Object.pp$9.semicolon (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:18 │ at Object.pp$8.parseExpressionStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/n │ at Object.pp$8.parseStatement (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry. │ at Object.pp$8.parseTopLevel (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.j │ at Object.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17935:15) │ at Function.parse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:17985:35) │ at Graph.contextParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/rollup@3.17.3/node_modules/rollup/dist/es/shared/node-entry.js:24381 │ at tryParse (file:///D:/work/projects/userquin/GitHub/userquin/unjs/unhead/node_modules/.pnpm/@rollup+plugin-commonjs@24.0.1_rollup@3.17.3/node_modules/@rollup/plugin-commo │ pos: 5, │ loc: { │ column: 5, │ file: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ line: 1 │ }, │ raisedAt: 16, │ frame: "1: type Booleanable = boolean | 'false' | 'true' | '';\n" + │ ' ^\n' + │ '2: type Stringable = string | Booleanable | number;\n' + │ '3: type Arrayable = T | Array;', │ id: 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ hook: 'resolveId', │ code: 'PLUGIN_ERROR', │ plugin: 'commonjs--resolver', │ watchFiles: [ │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\index.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\renderDOMHead.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\patchDomOnEntryUpdatesPlugin.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\setAttrs.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\dom\\src\\hash.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\index.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\schema.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\safeSchema.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\tags.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\head.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\packages\\schema\\src\\hooks.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\zhead@2.0.4\\node_modules\\zhead\\dist\\index.d.ts', │ 'D:\\work\\projects\\userquin\\GitHub\\userquin\\unjs\\unhead\\node_modules\\.pnpm\\hookable@5.5.1\\node_modules\\hookable\\dist\\index.d.ts' │ ] │ } └─ Failed in 3.9s at D:\work\projects\userquin\GitHub\userquin\unjs\unhead\packages\dom packages/ssr build$ unbuild . │ i Building @unhead/ssr │ √ Build succeeded for ssr │ dist/index.cjs (size: 3.17 kB, exports: encodeInnerHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString) │ dist/index.mjs (size: 3.07 kB, exports: encodeInnerHtml, propsToString, renderSSRHead, ssrRenderTags, tagToString) │ Σ Total dist size (byte size): 6.91 kB └─ Done in 3.9s D:\work\projects\userquin\GitHub\userquin\unjs\unhead\packages\dom:  ERR_PNPM_RECURSIVE_RUN_FIRST_FAIL  @unhead/dom@1.1.25 build: `unbuild .` Exit status 1  ELIFECYCLE  Command failed with exit code 1. ```
harlan-zw commented 1 year ago

Hey @LittleSound

Would you have any ideas on this? Happy to investigate otherwise

userquin commented 1 year ago

https://github.com/unjs/jiti/pull/134

ksenkso commented 9 months ago

I have a similar problem, but on the client side. I use a mixin to utilize the head component option (i'm migrating from vue 2 to vue 3) and when the route changes, the head option is called with the new route instead of the old one, which breaks the page because of the incorrect route params. So the component option is called on the route, where the component is not ment to render, which is unexpected.

It seems like this problem is caused by watchEffect in useClientHead running with the default { flush: 'pre' } option, which makes it to process the input when the route has been changed already, but the component itself is yet to be unmounted/deactivated. Using { flush: 'post' } for that watchEffect fixes it, running after the component has been changed - which at least on client side should be ok, I suppose.

I'm still digging into this to understand why flush option matters this much and maybe there is some other solution, but maybe someone here cane make use of this info. Currently I patched it in my own code, but I'll try toi come back if I find that my solution is the right one (or if i'm wrong and this need to be scraped).

UPD: it works fine when using useHead in setup, the issue is only with the mixin calling useHead in created().