question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

bluebird eval in toFastProperties triggers SyntaxError

See original GitHub issue

I’m trying to use lavamoat with the plaid API, which uses bluebird. I can imagine bluebird does some sort of monkey-patching that doesn’t mesh well with lavamoat. Any advice on how to proceed?

To reproduce the issue, I used lavamoat-browserify-examples/00-simple-cli with a small tweak:

add-bluebird.patch.txt

When I npm install; npm start and load the page in my browser, I get some diagnostics that I struggle to make sense of:

internalRequire:551 LavaMoat - Error evaluating module "2" from package "bluebird"
internalRequire @ internalRequire:551
requireRelative @ internalRequire:638
requireRelativeWithContext @ internalRequire:605
eval @ VM318:2
internalRequire @ internalRequire:586
loadBundle @ internalRequire:3976
(anonymous) @ internalRequire:4658
internalRequire:588 LavaMoat - Error instantiating module "1" from package "<root>"
internalRequire @ internalRequire:588
loadBundle @ internalRequire:3976
(anonymous) @ internalRequire:4658
internalRequire:589 Uncaught SyntaxError: possible direct eval expression rejected around line 5561
    at rejectSomeDirectEvalExpressions (internalRequire:1258)
    at rejectDangerousSources (internalRequire:1267)
    at Object.rewrite (internalRequire:1273)
    at eval (eval at createSafeEvaluatorFactory (bundle.js:1337), <anonymous>:19:57)
    at Array.reduce (<anonymous>)
    at eval (eval at createSafeEvaluatorFactory (bundle.js:1337), <anonymous>:4:53)
    at applyTransforms (eval at createSafeEvaluatorFactory (bundle.js:1337), <anonymous>:17:21)
    at safeEvalOperation (internalRequire:1353)
    at internalRequire:1425
    at realmEvaluate (internalRequire:1650)
callAndWrapError @ VM268:79
evaluate @ VM275:54
internalRequire @ internalRequire:549
requireRelative @ internalRequire:638
requireRelativeWithContext @ internalRequire:605
eval @ VM318:2
internalRequire @ internalRequire:586
loadBundle @ internalRequire:3976
(anonymous) @ internalRequire:4658

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
dckccommented, Dec 12, 2019

we found a work-around using browserfy transforms:

const { makeStringTransform } = require(‘browserify-transform-tools’)

module.exports = makeStringTransform('lavamoat-browserify-workarounds', { excludeExtension: ['.json'] }, (content, _, cb) => {
  const result = content
    // fix html comments
    .split('-->').join('-- >')
    // fix direct eval
    .split(' eval(').join(' (0, eval)(')
    .split('\neval(').join('\n(0, eval)(')

  cb(null, result)
})
0reactions
kumaviscommented, Dec 29, 2019

@dckc this workaround has been added into lavamoat-browserify on by default and uh not yet disable-able by an option

Read more comments on GitHub >

github_iconTop Results From Across the Web

bluebird eval in toFastProperties triggers SyntaxError · Issue #19 ...
I'm trying to use lavamoat with the plaid API, which uses bluebird. I can imagine bluebird does some sort of monkey-patching that doesn't...
Read more >
How does Bluebird's util.toFastProperties function make an ...
This code is never // reached but even using eval in unreachable code causes v8 // to not optimize functions. }.
Read more >
Warning for "unreachable expression after semicolon-less ...
It says "SyntaxError: unreachable expression after semicolon-less return statement", but the expression isn't actually unreachable, because the return is ...
Read more >
ses - UNPKG
665, SyntaxError: NativeError('%SyntaxErrorPrototype%'), ... 2215, // (using eval) or by invoking a previously saved reference to the originals.
Read more >
Free Automated Malware Analysis Service - Hybrid Analysis
Submit malware for free analysis with Falcon Sandbox and Hybrid Analysis technology. Hybrid Analysis develops and licenses analysis tools to ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found