-
Notifications
You must be signed in to change notification settings - Fork 144
Open
Description
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.
Minimal Reproduction Link
I have no idea how to reproduce this in isolation
Metadata
Metadata
Assignees
Labels
No labels