pocketbase / js-sdk

PocketBase JavaScript SDK

Home Page:https://www.npmjs.com/package/pocketbase

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto Cancellation issue

GD-coding opened this issue · comments

When using

pb.collection().getList(1, 25);

and then calling

pb.collection().getList(2, 25);

There is an auto cancellation. This seems like a bug to me, but maybe it is the intended purpose.

It is intended. See https://github.com/pocketbase/js-sdk#auto-cancellation.

The reason for the auto cancellation is that both requests will have the same requestKey, which by default is METHOD + path. Check the above link how to specify individual request keys or disable completely the auto cancellation.

To catch auto cancellation errors, you can wrap your calls with try/catch (or use the catch Promise function) and check the err.isAbort prop. It is safe to ignore auto cancellation errors.

try {
    ...
} catch (err) {
    if (!err.isAbort) {
        console.log("non auto cancel error", err);
    }
}