Skip to content

createDeferred hangs the process in nodejs #2570

@Sleepful

Description

@Sleepful

Describe the bug

using createDeferred within node, while using node -C browser file.js, causes the process thread to hang and never exit.

Add this to a file:

import { createSignal, createEffect, createRoot, createDeferred } from "solid-js";

function createCounter(initial = 0) {
  const [count, setCount] = createSignal(initial);
  const def = createDeferred(() => (count() * 2), { timeoutMs: 2000 })

  createEffect(() => {
    console.log(`Count changed, new value: ${count()}`);
  });

  function increment() {
    setCount((c) => c + 1);
  }

  function reset() {
    setCount(initial);
  }

  return { count, increment, reset, def };
}

createRoot((dispose) => {
  const { count, increment, reset, def } = createCounter(10);

  console.log(count())
  console.log(def())
  increment();
  console.log(count())
  console.log(def())
  reset();
  console.log(count())
  console.log(def())

  dispose();
});

Run it with node -C browser ./file.js, it will print out correctly but the process will not end properly.

Platform

OS: macOS
Browser: nodejs
Version: ^1.9.10

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