Skip to content

{@debug} doesn't work with dynamic block type in {#if} if exception is thrown #8455

@space-nuko

Description

@space-nuko

Describe the bug

If I write code like this I expect the data to be printed, but because accessing .missingTypeProp throws an exception it doesn't work.

It's because select_block_type preempts the block creation, which is where the console log is output

However if I replace {@debug} with {(console.log({ item }), '')} it does work

Reproduction

{#each state[id] as item, i}
    {@debug item}
    {#if item.missingTypeProp == "combo"}
        <Combo />
    {:else}
        <OtherWidget />
    {/if}
{/each}

Logs

Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'missingTypeProp')
    at select_block_type (ComfyPane.svelte?t=1680709132477:391:31)
    at create_each_block_1 (ComfyPane.svelte?t=1680709132477:397:35)
    at Array.create_default_slot (ComfyPane.svelte?t=1680709132477:527:20)
    at create_slot (chunk-PUOMPBAM.js?v=69346b91:70:25)
    at create_dynamic_element (Block.svelte:40:23)
    at create_fragment (Block.svelte:161:42)
    at init (chunk-PUOMPBAM.js?v=69346b91:1874:35)
    at new Block (Block.svelte:356:3)
    at createProxiedComponent (svelte-hooks.js?v=69346b91:341:9)
    at new ProxyComponent (proxy.js?v=69346b91:242:7)

System Info

System:
    OS: Windows 10 10.0.20348
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor
    Memory: 9.33 GB / 63.93 GB
  Binaries:
    Node: 18.15.0 - ~\AppData\Local\pnpm\node.EXE
    Yarn: 1.22.10 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 9.5.0 - ~\AppData\Local\pnpm\npm.CMD
  Browsers:
    Internet Explorer: 11.0.20348.380
  npmPackages:
    svelte: ^3.54.0 => 3.58.0
    vite: ^4.2.0 => 4.2.1

Severity

annoyance

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