denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
94.06k stars 5.23k forks source link

Error: Function called outside component initialization #21011

Open terrablue opened 10 months ago

terrablue commented 10 months ago

Hi, my framework supports Node, Deno and Bun. I get the following error (this is an error in Svelte, one of the supported frontend frameworks) when running it with Deno (deno run --allow-all npm:primate).

Error: Function called outside component initialization
    at get_current_component (file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/internal/lifecycle.js:11:32)
    at getContext (file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/internal/lifecycle.js:141:9)
    at file:///home/blue/projects/primatejs/app/node_modules/.deno/@primate+i18n@0.1.0/node_modules/@primate/i18n/src/svelte/locale.js:6:22
    at Object.subscribe (file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/store/index.js:82:11)
    at subscribe (file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/internal/utils.js:139:22)
    at file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/store/index.js:158:4
    at Array.map (<anonymous>)
    at file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/store/index.js:157:38
    at Object.subscribe (file:///home/blue/projects/primatejs/app/node_modules/svelte/src/runtime/store/index.js:82:11)
    at subscribe (file:///home/blue/projects/primatejs/app/node_modules/.deno/svelte@4.2.2/node_modules/svelte/src/runtime/internal/utils.js:139:22)
    at file:///home/blue/projects/primatejs/app/build/server/components/test/PostIndex.svelte.js:22:20
    at Object.$$render (file:///home/blue/projects/primatejs/app/node_modules/.deno/svelte@4.2.2/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
    at file:///home/blue/projects/primatejs/app/build/server/svelte_root.js:36:82
    at $$render (file:///home/blue/projects/primatejs/app/node_modules/.deno/svelte@4.2.2/node_modules/svelte/src/runtime/internal/ssr.js:156:16)
    at Object.render (file:///home/blue/projects/primatejs/app/node_modules/.deno/svelte@4.2.2/node_modules/svelte/src/runtime/internal/ssr.js:164:17)
    at render (file:///home/blue/projects/primatejs/app/node_modules/.deno/@primate+frontend@0.6.0/node_modules/@primate/frontend/src/frontends/svelte/imports.js:5:36)
    at file:///home/blue/projects/primatejs/app/node_modules/.deno/@primate+frontend@0.6.0/node_modules/@primate/frontend/src/frontends/common/handler.js:49:30
    at async handle (file:///home/blue/projects/primatejs/app/node_modules/.deno/@primate+session@0.13.0/node_modules/@primate/session/src/module.js:70:24)
    at async ext:deno_http/00_serve.js:451:22

The same code runs with npx primate, bun x primate and bun --bun x primate, which has me thinking this could be an issue in Deno's NPM support.

Following steps to reproduce,

  1. git clone https://github.com/primatejs/app
  2. cd app
  3. deno run --allow-all npm:primate
  4. open http://localhost:6161/svelte in your browser
ralyodio commented 10 months ago

I'm also seeing this. works fine in bun fwiw