Skip to content
This repository has been archived by the owner on Aug 11, 2021. It is now read-only.

ERROR TypeError: sort is not a function #67

Closed
netpoe opened this issue Apr 25, 2018 · 2 comments
Closed

ERROR TypeError: sort is not a function #67

netpoe opened this issue Apr 25, 2018 · 2 comments

Comments

@netpoe
Copy link

netpoe commented Apr 25, 2018

I'm running into a TypeError.

Using Angular ^5.2.0
ipfs ^0.28.2

In node_modules/ipld-dag-pb/src/dag-node/create.js:39

This is happening when I perform this:

import { Buffer } from 'buffer';

declare let require: any;

const streamBuffers = require('stream-buffers');
const IPFS = require('ipfs');
const node = new IPFS({
  repo: '../assets/ipfs'
});

...

upload(fileContent, fileObj) {
    this.progress = 0;

    let myReadableStreamBuffer = new streamBuffers.ReadableStreamBuffer({
      chunkSize: 25000
    });

    let stream = node.files.addReadableStream();

    stream.on('data', (ipfsFile) => {
      this.onFileUploadEnd.next({ ipfsFile, fileObj });

      console.log(node);
    });

    myReadableStreamBuffer.on('data', (chunk) => {
      this.progress += chunk.byteLength;

      let file = this.files[fileObj.index];
      file.progress += chunk.byteLength;
      file.pctg = (file.progress >= file.size) ?
        0 :
        this.fileProgressPerimeter - ((file.progress / file.size) * this.fileProgressPerimeter);

      this.onFileUpload.next(file);

      myReadableStreamBuffer.resume();
    });

    stream.write(myReadableStreamBuffer); // I BELIEVE THIS IS THE LINE THAT TRIGGERS THE ERROR

    myReadableStreamBuffer.put(Buffer.from(fileContent));
    myReadableStreamBuffer.stop();

    myReadableStreamBuffer.on('end', () => {
      console.log('END');
      stream.end();
    });

    myReadableStreamBuffer.resume();
  }
@victorb
Copy link
Member

victorb commented Apr 25, 2018

This was supposedly fixed in #65

@vmx
Copy link
Member

vmx commented May 10, 2018

I'm closing this issue as it should be fixed in more recent releases of js-ipfs. @netpoe If it isn't, please re-open this issue.

@vmx vmx closed this as completed May 10, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants