question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lack of pipe method?

See original GitHub issue

i installed sharp module based on the ‘Read Me’ document, simple test is ok, but i get the below error when excute my test code, lack of importing some other module?

My Ubuntu env(Ubuntu 14.04 LTS)

    uname -a
    Linux mao 3.13.0-34-generic #60-Ubuntu SMP Wed Aug 13 15:45:27 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

Test Code:

    var sharp = require('sharp');
    var http = require('http');
    require('stream');

    http.createServer(function(request, response) {
    response.writeHead(200, {'Content-Type': 'image/webp'});
    sharp('input.jpg').rotate().resize(200).webp().pipe(response);
    }).listen(8000);
    // Create HTTP server that always returns auto-rotated 'input.jpg',
    // resized to 200 pixels wide, in WebP format

The error log:

    sharp('input.jpg').rotate().resize(200).webp().pipe(response);
                                                     ^
    TypeError: Object [object Promise] has no method 'pipe'
            at Server.<anonymous> (/home/len/temp/nodejis/webp.js:10:50)
            at Server.emit (events.js:98:17)
            at HTTPParser.parser.onIncoming (http.js:2108:12)
            at HTTPParser.parserOnHeadersComplete [as onHeadersComplete] (http.js:121:23)
            at Socket.socket.ondata (http.js:1966:22)
            at TCP.onread (net.js:527:27)
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_lookup: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed
    (.:6385): GLib-CRITICAL **: g_hash_table_insert_internal: assertion 'hash_table != NULL' failed

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
lovellcommented, Aug 19, 2014

http.get() returns a request object rather than a Readable Stream response.

I recommend you use the request HTTP client.

You’ll need to move inputStream and transformer inside the scope of the closure passed to createServer().

var request = require('request');
var sharp = require('sharp');

http.createServer(function (req, res) {
  var inputStream = request('http://i.ebayimg.com/00/s/MTYwMFgxNjAw/z/C~EAAOSw~CRToq89/$_58.JPG');
  var transformer = sharp().resize(200);
  inputStream.pipe(transformer).pipe(res);
}).listen(8000);
3reactions
lenliucommented, Aug 19, 2014

Thanks, the test above is ok after reinstalling the sharp; but another problem when i replace input.jpg to stream, the HTTP request from browser can not return, the code is below:

var sharp = require('sharp');
var http = require('http');
var inputStream = http.get('http://i.ebayimg.com/00/s/MTYwMFgxNjAw/z/C~EAAOSw~CRToq89/$_58.JPG');
var transformer = sharp().resize(200);
http.createServer(function (req, res) {
  var outputStream = res;
  inputStream.pipe(transformer).pipe(outputStream); // coding according to the doc
}).listen(8000);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Losses in Pipes - Mechanical and Materials Engineering
This page provides a quick review of piping losses, starting with Bernoulli's Equation. The basic approach to all piping systems is to write...
Read more >
Equivalent Length Method - Minor Pressure Loss in Piping ...
An efficient and simple way to calculate the pressure loss in a piping system is the "Equivalent Pipe Length Method".
Read more >
Experiment #4: Energy Loss in Pipes - Mavs Open Press
The total energy loss in a pipe system is the sum of the major and minor losses ... Method. The friction factor is...
Read more >
Pipe Friction Loss Calculations - Pipe Flow Software
Calculating the friction loss in a pipe using the Darcy-Weisbach method.
Read more >
Pressure Loss from Fittings - Equivalent Length Method
The equivalent length method (L/D ratio) allows the user to describe the pressure drop through a fitting as a length of pipe. In...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found