Does your characteristic (defined on the ESP32) that you are trying to subscribe/notify to have the descriptor 0x2902 (CCC Descriptor) defined?
This is a requirement of the web-bluetooth implementation in Chrome per https://groups.google.com/a/chromium.org/g/web-bluetooth/c/TlHnA3hTksw
The other issue you could be running into is a problem with concurrency when writing to characteristics and introducing a delay could help. The comment from programmerRaj using an alert could be adding this delay, or the issue could also be due to interactivity.
I am also running into this problem (my BLE pererphial is defined/running in nodejs on a Raspberry pi 4), but for me, the characteristic does have the descriptor and I've already tried a delay. I'll try and come back and update this answer if I identify other scenarios that lead to this problem.