Skip to content

Commit

Permalink
Prevent from RangeError exceptions on large data
Browse files Browse the repository at this point in the history
On io.js 2.2.1 and 2.3.1 (by the time of writing it's the latest) I have this error:

```
RangeError: Maximum call stack size exceeded
  at String.match (native)
```

It happens only on the second pass while karma is working (auto watching and reruns the specs).

For more details read this issue:

nodejs/node#759

Similar issues:

thlorenz/convert-source-map#10
thlorenz/convert-source-map#11

Looks like this related to optimizations in V8 regex engine:
http://blog.chromium.org/2009/02/irregexp-google-chromes-new-regexp.html

Simply changing from `.+` to `..*` equivalent rule fixes an issue with match function.
  • Loading branch information
dmitry committed Jun 30, 2015
1 parent 20f54e9 commit 3ca125d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion index.js
Expand Up @@ -12,7 +12,7 @@ var createSourceMapLocatorPreprocessor = function(args, logger, helper) {

function inlineMap(inlineData){
var data;
var b64Match = inlineData.match(/^data:.+\/(.+);base64,(.*)$/);
var b64Match = inlineData.match(/^data:..*\/(..*);base64,(.*)$/);
if (b64Match !== null && b64Match.length == 3) {
// base64-encoded JSON string
log.debug('base64-encoded source map for', file.originalPath);
Expand Down

0 comments on commit 3ca125d

Please sign in to comment.