Skip to content

Abort signals for remote functions #14502

@mihaipoenaru

Description

@mihaipoenaru

Describe the problem

As I understand it, when a remote function fires on the client, it's actually a fetch wrapper. I have a case where I have to call a remote whenever an input changes to search for something, as the user types. Now this is an obvious race condition, depending on how flaky the network decides to be, so I need to cancel a request as soon as the user changes the input, so that old requests don't mess up my result section.

Now I could just make a REST api and just manually fetch it, making it possible to use abort signals, but surely there should be some way for a remote function to be able to receive an abort signal. I've tried to search in the docs, but I couldn't find a way to do it, at least not an obvious one.

Describe the proposed solution

The most straightforward way is to have a config object that would contain some options for the underlying fetch call, one of which would be the abort signal. Otherwise make the remote functions abortable directly, somehow

Alternatives considered

Like I said, a classic api with a manual fetch in sveltekit, but now that we have remote function, they should technically replace all that nonsense.

Importance

nice to have

Additional Information

No response

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