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.

Request not being executed

See original GitHub issue

Operating System: macOS Mojave 10.4.5

Platform: Electron 5.0.6

Curl: curl 7.65.1 (x86_64-apple-darwin18.6.0) libcurl/7.65.1 OpenSSL/1.0.2s zlib/1.2.11 brotli/1.0.7 c-ares/1.15.0 libssh2/1.9.0 nghttp2/1.39.1 librtmp/2.3 Release-Date: 2019-06-05 Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB SPNEGO SSL TLS-SRP UnixSockets

Installed with the command: npm_config_curl_static_build=true npm_config_runtime=electron npm_config_target=$(yarn --silent electron --version) npm_config_disturl=https://atom.io/download/atom-shell yarn add node-libcurl

I’m trying to make node-libcurl work with no success. After reading the instructions to install the package for Electron (see above), and executing the following:

const { Curl } = require('node-libcurl');
 
const curl = new Curl();
 
console.log(curl);
curl.setOpt('URL', 'www.google.com');
curl.setOpt('FOLLOWLOCATION', true);
 
curl.on('end', function (statusCode, data, headers) {
  console.info(statusCode);
  console.info('---');
  console.info(data.length);
  console.info('---');
  console.info(this.getInfo( 'TOTAL_TIME'));
  
  this.close();
});
 
curl.on('error', curl.close.bind(curl));
curl.perform();

the end callback is not being triggered, but if I put the same code under a basic Node app it works perfectly.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
vierarbcommented, Aug 26, 2019

To make it work with Electron, the library versions when executing curl --version and node -p process.versions must be the same, specifically brotli, OpenSSL, nghttp2 and zlib, as said in the documentation.

curl --version

curl 7.65.3 (x86_64-apple-darwin18.7.0) libcurl/7.65.3 OpenSSL/1.1.1c zlib/1.2.11 brotli/1.0.7 c-ares/1.15.0 libidn2/2.2.0 libpsl/0.21.0 (+libidn2/2.2.0) libssh2/1.9.0 nghttp2/1.39.2
Release-Date: 2019-07-19
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp
Features: AsynchDNS brotli GSS-API HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz Metalink NTLM NTLM_WB PSL SPNEGO SSL TLS-SRP UnixSockets

node -p process.versions

{
  node: '12.8.1',
  v8: '7.5.288.22-node.16',
  uv: '1.30.1',
  zlib: '1.2.11',
  brotli: '1.0.7',
  ares: '1.15.0',
  modules: '72',
  nghttp2: '1.39.2',
  napi: '4',
  llhttp: '1.1.4',
  http_parser: '2.8.0',
  openssl: '1.1.1c',
  cldr: '35.1',
  icu: '64.2',
  tz: '2019a',
  unicode: '12.1'
}

1. Update libraries

  • brew upgrade c-ares
  • brew upgrade nghttp2
  • brew install openssl@1.1

2. Install cURL from source

I tried to install a few cURL packages from brew, but none worked, since there was no way to specify all flags I needed. Building cURL from source solved the problem. This is the configure options I used, the important ones are those that set a path.

./configure \
--disable-debug \
--disable-dependency-tracking \
--disable-silent-rules \
--with-libidn2 \
--with-nghttp2=/usr/local/opt/nghttp2 \
--with-ssl=/usr/local/opt/openssl@1.1 \
--with-ca-bundle=/usr/local/etc/openssl@1.1/cert.pem \
--with-ca-path=/usr/local/opt/openssl@1.1/certs \
--enable-ares=/usr/local/opt/c-ares/lib \
--with-libssh2 \
--without-librtmp \
--with-gssapi \
--with-libmetalink
make && make install

3. Reinstall node to link the new versions we just installed in step 1.

4. Install node-libcurl

npm_config_build_from_source=true \
npm_config_runtime=electron \
npm_config_target=$(yarn --silent electron --version) \
npm_config_disturl=https://atom.io/download/atom-shell \
yarn add node-libcurl

Et voilà!

0reactions
JCMaiscommented, Aug 21, 2019

Hey, glad you got it working! If possible can you post the steps you took to identify the problem and how you solved it? It would be great for others having the same problem.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The HTTP request is not being executed in response - Flutter ...
The problem is that your emulator doesn't understand localhost, like your machine's localhost, so to access it you need to switch to 10.0....
Read more >
The HTTP request is not being executed in response #384
I'm trying to perform a request to a Web API written in C# (.NET Core). The endpoint runs a async function and return...
Read more >
HTTP Requests not being executed until function is finished
I'm running UE 4.8.3 and am trying to get an image from an URL. All in all, the code works for creating a...
Read more >
Invoke - AWS Lambda - AWS Documentation
One of the parameters in the request is not valid. HTTP Status Code: 400. InvalidRequestContentException. The request body could not be parsed as...
Read more >
PUT request not being executed properly - CodeRanch
I am just testing my put request. It is working fine with Postman on Spring Boot, so there is nothing wrong with the...
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