promesa icon indicating copy to clipboard operation
promesa copied to clipboard

Stack overflow resolving a promise returned by the VS Code API

Open PEZ opened this issue 1 month ago • 5 comments

Hi! Thanks for providing Promesa! I totally love it. ♥️

When investigating an issue on Joyride, I noticed that with Promesa versions later than 10.0.594 this function throws an error about exceeding the stack size:

(defn say-clipboard-content! []
  (p/let [; text (.then (vscode/env.clipboard.readText) identity) ; works fine
          text (vscode/env.clipboard.readText) ; crashes
          ]
    (vscode/window.showInformationMessage (str "clipboard contains: " text))))

As I don't know any other promise that encounters the error, I created a tiny VS Code extension to reproduce: https://github.com/PEZ/promesa-stack-overflow

Let me know if I can help with debugging in any way.

PEZ avatar Nov 02 '25 17:11 PEZ

My wild guess would be that this issue is introduced in

In this version, one of the problems that existed since the birth of this library has been corrected, related to the fact that the default implementation of js/Promise makes it impossible to nest promises.

11.0.664

Possibly the VSCode API returns a nested promise and promesa somehow gets stuck in a loop because of this? Again, just a guess..

borkdude avatar Nov 02 '25 19:11 borkdude

Thanks for the detailed report and repo repo, I will try to look on it ASAP

niwinz avatar Nov 03 '25 13:11 niwinz

Good news, the issue is already fixed on master I have planning releasing a first RC this week but I can't promise nothing because i have a pretty busy days

niwinz avatar Nov 04 '25 07:11 niwinz

Great! I should have tried that! I could confirm with the repro project, which has been updated to say as much.

PEZ avatar Nov 04 '25 08:11 PEZ

Out of curiosity, which commit was the fix?

borkdude avatar Nov 04 '25 08:11 borkdude

I don't know, but probably some bug on how internal resolution on the custom Promise impl on JS...

niwinz avatar Dec 15 '25 11:12 niwinz

In any case, released 12.0.0-RC2 that should have this fix. So closing. If you find something strange with RC2, please report :D Thanks to all

niwinz avatar Dec 15 '25 11:12 niwinz