Skip to content

Problems running legacy code in server.js #16083

@ispyinternet

Description

@ispyinternet

Describe the bug

I have been developing an app, which I have now started to migrate to svelte 5.

Everything works in dev, but when I build it using adapter-node the site breaks.

I have a simple legacy component, that uses both getContext and $:

With $: I get the error from effects.js,

Cannot read properties of null (reading 'r1')

from this code

export function legacy_pre_effect(deps, fn) {

If I remove the reactive $: syntax and just leave the getContext I get:

Cannot read properties of null (reading 'u')

from this code

export function init(immutable = false) {

In both cases it seems like context.l being null is the culprit. At its simplest the failing legacy component:

    import { getContext } from 'svelte';
    import { CONTEXT_PAGE_STORE } from '$lib/config/context';
    
    const page: Writable<Types.PageState> = getContext(CONTEXT_PAGE_STORE);
</script>

{#if $page.viewState == 'state_loading'}
    <div class="loading">
    </div>
{/if}

Reproduction

Will create and update the issue

Logs

System Info

System:
    OS: Linux 6.1 Amazon Linux 2023
    CPU: (4) x64 Intel(R) Xeon(R) Platinum 8175M CPU @ 2.50GHz
    Memory: 6.53 GB / 15.41 GB
    Container: Yes
    Shell: 5.2.15 - /bin/bash
  Binaries:
    Node: 20.11.0 - ~/.nvm/versions/node/v20.11.0/bin/node
    Yarn: 1.22.19 - ~/.npm-global/bin/yarn
    npm: 8.15.1 - ~/.npm-global/bin/npm
    pnpm: 8.15.0 - ~/.local/share/pnpm/pnpm
  npmPackages:
    svelte: ^5.25.6 => 5.25.6

Severity

blocking all usage of svelte

Metadata

Metadata

Assignees

No one assigned

    Labels

    awaiting submitterneeds a reproduction, or clarification

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions