Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: using localStorage(sessionStorage) and timer function in vue sfc will block building #55

Merged
merged 2 commits into from
Jun 16, 2021

Conversation

xuzaixian
Copy link
Contributor

url options is required in jsdom constructor when using localStorage or sessionStorage.
Otherwise building will fail by [DOMException [SecurityError]: localStorage is not available for opaque origins]

Relative Issue

@xuzaixian xuzaixian changed the title fix: localStorage is not available for opaque origins WIP: fix: localStorage is not available for opaque origins Jun 16, 2021
@antfu antfu closed this Jun 16, 2021
@antfu antfu reopened this Jun 16, 2021
@antfu antfu closed this Jun 16, 2021
@antfu antfu reopened this Jun 16, 2021
@antfu
Copy link
Member

antfu commented Jun 16, 2021

Ah, sorry, mis-operate 😅

@xuzaixian
Copy link
Contributor Author

xuzaixian commented Jun 16, 2021

There is another issue about jsdom.
RangeError: Maximum call stack size exceeded will block building when using timer function like setTimeout in vue sfc.

Error Stack:

RangeError: Maximum call stack size exceeded
    at Window.setTimeout (/Users/XXX/node_modules/.pnpm/jsdom@16.5.3/node_modules/jsdom/lib/jsdom/browser/Window.js:467:55)
    at timerInitializationSteps (/Users/XXX/node_modules/.pnpm/jsdom@16.5.3/node_modules/jsdom/lib/jsdom/browser/Window.js:537:25)
    at Window.setTimeout (/Users/XXX/node_modules/.pnpm/jsdom@16.5.3/node_modules/jsdom/lib/jsdom/browser/Window.js:467:12)
    at timerInitializationSteps (/Users/XXX/node_modules/.pnpm/jsdom@16.5.3/node_modules/jsdom/lib/jsdom/browser/Window.js:537:25)

And Trace Stack In JSDOM Source Code:

RangeError: Maximum call stack size exceeded
    at console.value (internal/console/constructor.js:258:20)
    at console.warn (internal/console/constructor.js:363:26)
    at consoleCall (<anonymous>)
    at console.trace (internal/console/constructor.js:409:10)
    at VirtualConsole.onMethodCall (/Users/XXX/node_modules/.pnpm/jsdom@16.6.0/node_modules/jsdom/lib/jsdom/virtual-console.js:22:29)
    at VirtualConsole.emit (events.js:315:20)
    at Object.trace (/Users/XXX/node_modules/.pnpm/jsdom@16.6.0/node_modules/jsdom/lib/jsdom/browser/Window.js:842:30)
    at timerInitializationSteps (/Users/XXX/node_modules/.pnpm/jsdom@16.6.0/node_modules/jsdom/lib/jsdom/browser/Window.js:539:15)
    at Window.setTimeout (/Users/XXX/node_modules/.pnpm/jsdom@16.6.0/node_modules/jsdom/lib/jsdom/browser/Window.js:467:12)
    at timerInitializationSteps (/Users/XXX/node_modules/.pnpm/jsdom@16.6.0/node_modules/jsdom/lib/jsdom/browser/Window.js:541:25)

I found out we can use virtualConsole options in constructor to fix this.

Maybe I should rename this pr to fix: some jsdom issue 😅

@xuzaixian xuzaixian changed the title WIP: fix: localStorage is not available for opaque origins fix: using localStorage(sessionStorage) and timer function in vue sfc will block building Jun 16, 2021
@antfu antfu merged commit efb0648 into antfu-collective:main Jun 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants