igv.js: Uncaught (in promise) RangeError: Invalid array length

Using igv-1.0.0-rc1.js, I get the following error in my console:

Uncaught (in promise) RangeError: Invalid array length(…)
   (anonymous function) @ igv-1.0.0-rc1.js:3550

This seems to happen with a somewhat sizeable bigwig file, 58M, representing only chr22.

The file itself was created from a bedgraph --> bigwig using the UCSC bedGraphToBigWig conversion utility. A smaller file (1.6M) converted from a subset of the same bedgraph data works just fine.

Is there a size limit we should be aware of?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (10 by maintainers)

Most upvoted comments

Great, thanks.
FYI, I was able to fix my code above, by refactoring the return:

    def generate(path, begin, end):
        with open(path, 'rb') as f:
            f.seek(begin)
            yield f.read(end-begin+1)

    response = Response(generate(full_path, begin, end), status=status, mimetype="application/octet-stream", headers=headers, direct_passthrough=True)

    return response

So, IT WORKS. hooray.

I will be looking at apache too as i move toward production. Thank you so much for your help!

Implementing a production web server is not a trivial task, I don’t know much about Flask but if you have to code support for this yourself its surprising. If you serve your files from any host other than the host serving the web page you’ll also have to deal with CORS and preflight requests.

Ok, I’ve been trying to track this down for the better part of the day. I’m running a flask app, and now am setting my own content headers like:

@app.route('/track_data/<path>')
def track_data_files(path):
    full_path = os.path.join(os.path.dirname(__file__), TRACK_FILES_DIR, path)
    # TODO security check - only files under TRACK_FILES_DIR should be accessible

    headers = Headers()
    headers.add('Content-Disposition', 'attachment', filename=path)
    headers.add('Content-Transfer-Encoding', 'binary')

    status = 200
    size = os.path.getsize(full_path)
    begin = 0
    end = size-1

    if request.headers.has_key('Range'):
        status = 206
        headers.add('Accept-Ranges', 'bytes')
        ranges = re.findall(r"\d+", request.headers["Range"])
        begin  = int( ranges[0] )
        if len(ranges)>1:
            end = int( ranges[1] )
        headers.add('Content-Range','bytes %s-%s/%s' % (str(begin),str(end),str(end-begin)) )

    headers.add('Content-Length', str((end-begin)+1))

    response = Response(file(full_path), status=status, mimetype="application/octet-stream", headers=headers, direct_passthrough=True)

    return response

Now, I get past the error dealing with range queries specifically. BUT, I now get that pesky array error again. It seems it is tracked down to near line 3551 in igv.js code:

bufferedReader.dataViewForRange({start: filePosition, size: 4}, false).then(function (dataView) {
    var binaryParser = new igv.BinaryParser(dataView, self.littleEndian);

    var type = binaryParser.getByte();
    var isLeaf = (type === 1) ? true : false;
    var reserved = binaryParser.getByte();
    var count = binaryParser.getShort();

where it seems count=-30577. FWIW, I am running on MacOS 10.11.4, Chrome browser.