In cpp/async/handle_base.hpp, cancel() marks an unresolved result as cancelled under the spin lock. If a bg_queue_promise task has already passed its initial cancellation check and is running, its later set_value()/set_exception() replaces the cancelled optional result without checking is_cancelled(). The promise can then report a successful completion after cancel() returned true (while the callback was cleared). The tracked path is async::run_on_main/run_on_bg -> run_ -> bg_queue_promise::call -> handle_base setters; run_on_main has production callers in deeplake_api/dataset.hpp and deeplake_pg/table_data_impl.hpp. A narrow source candidate guards completion setters against replacing cancellation. No tests/builds were run.
In cpp/async/handle_base.hpp, cancel() marks an unresolved result as cancelled under the spin lock. If a bg_queue_promise task has already passed its initial cancellation check and is running, its later set_value()/set_exception() replaces the cancelled optional result without checking is_cancelled(). The promise can then report a successful completion after cancel() returned true (while the callback was cleared). The tracked path is async::run_on_main/run_on_bg -> run_ -> bg_queue_promise::call -> handle_base setters; run_on_main has production callers in deeplake_api/dataset.hpp and deeplake_pg/table_data_impl.hpp. A narrow source candidate guards completion setters against replacing cancellation. No tests/builds were run.