Flow: Fatal error: exception Invalid_argument("String.sub / Bytes.sub")

Created on 3 Dec 2015  路  21Comments  路  Source: facebook/flow

When running flow, I get a fatal error:

Fatal error: exception Invalid_argument("String.sub / Bytes.sub")

I have an empty .flowconfig created with flow init. I installed flow via npm install flow-bin, but that downloads the released binary so I assumed it makes no difference.

Versions:
OS X 10.10.5
Flow: OS X Binaries: v0.19.0/flow-osx-v0.19.0.zip
npm 2.14.2
node v4.0.0

Most helpful comment

runkillall flow
then and run flow.

All 21 comments

I'm also seeing this on my project.

OS X 10.10.5
Flow 0.19.0
npm 3.3.9
node v5.0.0

looking at the places we call String.sub, it's most likely while trying to print an error. can you try with --old-output-format? that'll help figure out what the error struct looks like so we can repro with the new printer.

$ flow check --old-output-format

/Users/danvk/github/pileup.js/node_modules/npmconf/test/fixtures/package.json:1:3,2: Unexpected end of input

Found 1 error

Adding .*node_modules/npmconf.* to the ignore section of my .flowconfig made the error go away.

hrm, that's an empty file. we have a unit test for that, I think because of this exact npm module, since it has invalid files in its tests... I'll try to repro.

our unit tests run with --old-output-format so they pass... but it repros if you do flow check tests/node_tests/ without --old-output-format.

I tried it with the --old-output-format as you adviced. I get the same error as @danvk but from a different module apparently:

/My/Project/Path/node_modules/david/node_modules/npm/test/fixtures/config/package.json:1:3,2: Unexpected end of input

found the problem, fix incoming. ignoring .*node_modules/npm/test/.* is not a bad idea anyway, and should work around this in the meantime.

That was fast, thanks! :)

Thanks @mroch. Does this merit a 0.19.1 bugfix release?

Yep! We're cherry picking the fix into a 0.19.1 release. First time doing it this way, so hopefully we don't ruin everything!

Ok 0.19.1 is tagged and released.

Thanks for the error report, thanks for using flow, and thanks for your patience!

I am getting this same error and not seeing line numbers when I use old output format so rather tricky fixing things.

Flow, a static type checker for JavaScript, version 0.22.1
Linux worksharexps-XPS-15-9530 3.19.0-43-generic #49-Ubuntu SMP Sun Dec 27 19:43:07 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

NODE_DEBUG=* ./node_modules/.bin/flow
Fatal error: exception Invalid_argument("String.sub / Bytes.sub")
$ NODE_DEBUG=* ./node_modules/.bin/flow --old-output-format

lib/support.js: return
Missing annotation

support.js:99:4,4: return
Missing annotation

support.js: return
Missing annotation

lib/support.js: return
Missing annotation

lib/support.js: return
Missing annotation

lib/support.js: return
Missing annotation

Found 6 errors

After some investigation it seems the flow parser will choke on this:
function x() //: function
{
}

but not
function x() /*: function */
{
}

my bad assumption about how the annotation comments could be formatted.

Just had this issue in Flow v0.47. Adding .*/node_modules/npm/test/.* to the [ignore] section of .flowconfig resolved it.

Same, I'm on 0.59.0.

Same error on 1.4.0, but none of these [ignore]s fixed it and the --old-output-format is now disabled. Is there any other way I can get a more useful error out of this? (eventually found the problem folder (something in node_modules) by ignoring everything and slowly adding them back, but it would have been great to have a useful error from the start...)

got same error on latest flow version (0.66.0)

Unhandled exception: Invalid_argument("String.sub / Bytes.sub")
Raised at file "pervasives.ml", line 33, characters 20-45
Called from file "string.ml", line 47, characters 2-23
Called from file "src/common/errors/errors.ml", line 2045, characters 44-70
Called from file "list.ml", line 96, characters 24-34
Called from file "src/common/errors/errors.ml", line 2014, characters 46-1023
Called from file "list.ml", line 96, characters 24-34
Called from file "src/common/errors/errors.ml", line 2007, characters 32-1023
Called from file "map.ml", line 286, characters 19-24
Called from file "map.ml", line 285, characters 19-27
Called from file "src/common/errors/errors.ml", line 1999, characters 22-1023
Called from file "src/common/errors/errors.ml", line 2400, characters 8-170
Called from file "src/common/errors/errors.ml", line 2570, characters 12-320
Called from file "list.ml", line 85, characters 12-15
Called from file "src/common/errors/errors.ml", line 2582, characters 8-62
Called from file "src/flow.ml", line 82, characters 6-34

Managed to find the source of the errors with flow --json --pretty (cc @toddmedema)

Just encountered this problem. Went away after I forced the server to reinitialise.

@caoilte I've also been getting a surprising number of errors about node_modules that are fixed with a server restart. A bit disappointed that that's even a problem... seems like a pretty big bug with the server system.

runkillall flow
then and run flow.

Was this page helpful?
0 / 5 - 0 ratings