public function regenerate(): Promise
    {
        return $this->pending = call(function () {
            if ($this->pending) {
                yield $this->pending;
            }

            if ($this->id === null || !$this->isLocked()) {
                throw new \Error('Cannot save an unlocked session');
            }

            $newId = yield $this->storage->create();

            yield $this->storage->save($newId, $this->data);
            yield $this->storage->save($this->id, []);

            $this->id = $newId;
            $this->status = self::STATUS_READ | self::STATUS_LOCKED;

            return $this->id;
        });
    }