[2.0.4] An action started from a cleanup that only waits holds back a later, unrelated action's writes

Ouverte
#5,251 0 commentaires 0 réactions 0 personnes assignées Voir sur GitHub

Les mainteneurs répondent en général sous 1 jour

@yumemi-thomas y travaille déjà.

Depuis le 27/11/2026.

  • #5242 par @yumemi-thomas — ouverte
  • #5252 par @yumemi-thomas — fermée sans fusion

Évaluation

Difficulté
4/5
Temps estimé
3-5 jours
Accessibilité débutants
45/100
Type d'issue
Bug
Clarté
Clairement spécifiée
Activité
Active
Stack technique
javascript, typescript

Piste de recherche

Start with core/scheduler.ts, especially the logic that clears flushTransaction after a transaction queues no writes, then reproduce with the linked Solid playground using the provided wait, bump, and cleanup flow. The bug is done when bump() commits its signal update immediately even while wait() remains suspended, without regressing the related cleanup case in #5242.

Rédigé par le modèle d'indexation à partir du texte de l'issue.

Description

A cleanup starts an action that writes nothing and just waits. While it waits, an unrelated action sets a signal and ends. That write should show right after, but it stays hidden until the cleanup's action ends. Started outside a cleanup, the same waiting action doesn't hold anything back.

Reproduction

Open in the Solid playground (2.0.4)

import { createSignal, createEffect, action, Show } from "solid-js";

// Writes nothing; waits until "3. finish" is clicked.
let release: (() => void) | undefined;
const wait = action(function* () {
  yield new Promise<void>(r => (release = r));
});

function Panel() {
  createEffect(
    () => 1,
    () => () => void wait() // the effect's cleanup starts the waiting action
  );
  return <p>panel is open</p>;
}

export default function App() {
  const [open, setOpen] = createSignal(true);
  const [count, setCount] = createSignal(0);
  const close = action(function* () {
    setOpen(false);
  });
  const bump = action(function* () {
    setCount(2); // unrelated to `wait`
  });

  return (
    <>
      <button onClick={() => close()}>1. close panel</button>
      <button onClick={() => bump()}>2. set count to 2</button>
      <button onClick={() => release?.()}>3. finish</button>
      <Show when={open()}>
        <Panel />
      </Show>
      <p>count: {count()}</p>
    </>
  );
}

Steps

  1. Click 1. close panel. The cleanup starts wait().
  2. Click 2. set count to 2.
  3. Click 3. finish.

Expected

count: 2 after step 2. bump and wait share nothing, so bump commits on its own (D-4, D-9).

Actual

count: 0 after step 2, and count: 2 only after step 3. If the promise never settles, count never shows 2. Calling wait() from the close button instead of the cleanup gives count: 2 after step 2.

Same in 2.0.3, 2.0.4 and main (510bb8d01), dev and prod.

Cause

The cleanup runs while the closing action lands, and wait() opens a transaction that stays open because it yields. It queued no writes, so the flush ends without clearing flushTransaction (core/scheduler.ts), and the waiting action stays the current transaction. bump() joins it instead of opening its own, so its write waits for wait.

Similar to #3141 (fixed in #3145) but through a cleanup. #5242 covers the case where the cleanup's action writes an optimistic value, not this one.

Langage dominant
TypeScript
Étoiles
37k
Forks
1.2k
Merge moyen
8 h 43 min
PR mergées (30 j)
365

Préparer son environnement

Par où commencer

  1. Lisez l'issue en entier, puis le guide de contribution du projet.
  2. Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
  3. Forkez le dépôt et travaillez sur une branche.
  4. Ouvrez une pull request qui référence le numéro de l'issue.

Autres issues de solidjs/solid

Toutes les issues de solidjs/solid

Issues similaires

Plus d'issues TypeScript

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.