Skip to content

createScheduled crashes solid when changing route #805

@masylum

Description

@masylum

Describe the bug

This is what's happening:

const scheduled = createScheduled((fn) => debounce(fn, 10_000))
const debouncedIsDirty = createMemo((prev: boolean) => {
  const current = isDirty()
  return scheduled() ? current : prev
}, isDirty())

createEffect(() => {
  if (!debouncedIsDirty()) return
  updatePost(props.post)
})


onCleanup(() => {
  if (!isDirty()) return
  updatePost(props.post)
})

I'm using createScheduled to debounce a memo. The idea is that when a form becomes dirty, we want to save that form. But we don't want to overwhelm the server, so we wait for 10s window. We also force saving the post on cleanup.

If I edit the form and then I click on a link to navigate away, the whole thing explodes. I've commented out the scheduled code, and it is indeed the culprit. I've also waited 10s, and it also works. It only happens when I navigate away during that time.

Image

Minimal Reproduction Link

I have no idea how to reproduce this in isolation

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