← All tasks
javascriptmafintosh/tar-stream #32Not a task: already works

TypeError: Cannot read property 'corked' of undefined

envgap__mafintosh__tar-stream-32

01 / FAILURE SIGNATURE

As reported upstream

TypeError: Cannot read property 'corked' of undefined
Not a benchmark task.
  • The project already builds and runs before the fix, so there is nothing to repair.

02 / ENVIRONMENT RECIPE

Base commit
5d6f693f952df77259c6f427994f91083ae645bf
Manifest
package.json
Reproduce
Awaiting issue-specific recipe
Run under trace
Awaiting a meaningful runtime command

03 / ORIGINAL ISSUE TEXT

mafintosh/tar-stream #32 · read the original issue
when trying to do the following:

```
            var readStream = fs.createReadStream(tarballPath);
            var extractStream = tar.extract(nodeModulesPath);

            readStream
                .pipe(zlib.createGunzip())
                .pipe(extractStream);

            readStream.on('error', callback);
            extractStream.on('error', callback);
            extractStream.on('finish', callback);
```

I keep getting the following error in some cases. The only difference between the case where things fail and where things don't fail is when the tarball already exists on disk before running the script (doesn't fail) and when i create the tarball and try to extract it (but only after the finish event on the `tar.pack(nodeModulesPath)`). I've run a fs.existsSync call before the code above to confirm that the tarball exists and the node modules path does not.

```
TypeError: Cannot read property 'corked' of undefined
    at Writable.end (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:429:12)
    at emptyStream (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:18:5)
    at onheader (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:135:34)
    at Extract._write (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:207:8)
    at doWrite (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:279:12)
    at writeOrBuffer (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:266:5)
    at Writable.write (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:211:11)
    at write (_stream_readable.js:601:24)
    at flow (_stream_readable.js:610:7)
    at Gunzip.pipeOnReadable (_stream_readable.js:642:5)
```

This appears to be caused by the fact that `_writableState` is on the `_parent` property of the Source instance and not on the stream object itself. 

I tried adding a line to the source instantiation to pass this property through so it's available in `s.end()`, but then I get the following error:

```
Error: write after end
    at writeAfterEnd (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:161:12)
    at Writable.write (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:208:5)
    at Writable.end (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/node_modules/readable-stream/lib/_stream_writable.js:426:10)
    at Extract._write (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:203:12)
    at Extract._continue (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:171:28)
    at oncontinue (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:62:10)
    at onheader (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:143:5)
    at Extract._write (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:207:8)
    at Extract._continue (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:171:28)
    at oncontinue (/Users/andrewdeandrade/code/unpm-install/node_modules/tar-fs/node_modules/tar-stream/extract.js:62:10)
```

My first intuition is that https://github.com/mafintosh/tar-stream/blob/master/extract.js#L31 should read `PassThrough.call(this, self);`, but that didn't fix the problem either (but still might be something you want to add)

I tried checking the value of _writableState all the way through the instantiation stack. It's defined at the end of the constructor function for Writable(), but is undefined after the `Writable.call(options)` in the instantiation function of Duplex.

Any ideas on what could be causing this and how to fix it?
Continue on GitHub ↗

04 / LABELS

Labels from the report text only; not yet run

No supported category has been assigned.

Label rules and the text that matched
[]