Incompatibility with Bluebird-based libraries (e.g. AggLayer’s lxly.js) due to SES stripping Promise.try
When bundling and loading lxly.js (AggLayer’s cross-chain client) inside a MetaMask Snap, the Snap’s SES sandbox immediately crashes with errors around Promise.try being removed. Under the hood, lxly.js depends on Bluebird, which monkey-patches the global Promise by adding methods like Promise.try. SES proactively deletes any non-standard intrinsics (including Bluebird’s augmentations), and as soon as Bluebird code attempts to access or redefine Promise.try, it throws an irrecoverable error:
✖ Error: Failed to evaluate snap bundle in SES. This is likely due to an incompatibility with the SES environment in your snap. Received the following error from the SES environment: Removing intrinsics.Promise.try {}
Because SES strips these extensions at startup, lxly.js (and any library that pulls in Bluebird) cannot function in a Snap.
Links to lxly.js :- https://www.npmjs.com/package/@maticnetwork/lxlyjs https://github.com/0xPolygon/lxly.js https://github.com/BrianSeong99/Agglayer_UnifiedBridge
Hi there!
As far as I can tell lxly does not use Promise.try, that being said we are fixing the warning you see for Promise.try in an upcoming release.
I think the problem here is something else though as I see problems with env variables just running lxly in Snaps:
[TypeError <Object <Object <[Object: null prototype] {}>>>: Cannot read properties of undefined (reading 'env'). Seemingly from https://github.com/0xPolygon/lxly.js/blob/main/src/utils/http_request.ts#L3
Can you share more about how you are trying to use this library?
Thanks a lot @FrederikBolding for responding .
We are using these scripts to call bridgeAsset and claimAsset function from within the snap , but the build fails throwing the Promise.tryerror .
https://github.com/BrianSeong99/Agglayer_UnifiedBridge/tree/main/scripts/src
@AkshatGada Are you still seeing this issue?
Please open a new issue if you are still having issues.