snowflake-connector-nodejs
snowflake-connector-nodejs copied to clipboard
"got" package ability to make http(s)-requests is broken after the call snowflake.createConnection
-
What version of NodeJS are you using (
node --version
andnpm --version
)? Nove version: v12.22.4 npm version: 6.14.11 -
What operating system and processor architecture are you using?
Windows: Windows 10 Pro Version: 10.0.19044 build 19044
-
What are the component versions in the environment (
npm list
)? got: 11.8.3 snowflake-sdk: 1.6.5 typescript: 4.4.2 -
What did you do?
import snowflake, { Connection } from 'snowflake-sdk';
import got from 'got';
const conn = snowflake.createConnection({
account: '',
username: '',
password: '',
warehouse: '',
database: '',
schema: '',
authenticator: 'SNOWFLAKE'
});
const res = await got.get('https://www.google.com');
- What did you expect to see?
HTTP 200 response with HTML in a response body
- What did you see instead?
Error:
"name": "RequestError",
"code": "ECONNREFUSED",
"message": connect ECONNREFUSED 127.0.0.1:443
stacktrace:
RequestError: connect ECONNREFUSED 127.0.0.1:443
at ClientRequest.
- Add this to get standard output.
var snowflake = require('./snowflake');
snowflake.configure(
{
logLevel: 'trace'
});
No trace messages in the console
Please take into account this https://github.com/sindresorhus/got/issues/1572 and it seems you need to update https-proxy-agent
package version from 3.0 to 5.0 in order to fix this bug
You don't even need to call createConnection
, just requiring the snowflake-sdk
breaks it for me:
const got = require("got");
require("snowflake-sdk"); // if I comment-out this line then the code works fine
(async () => {
const { statusCode } = await got.get("https://google.com");
console.log(statusCode);
})();
You don't even need to call
createConnection
, just requiring thesnowflake-sdk
breaks it for me:
For JS - yes, you're quite right. For TS - it's not that, after a compilation to JS it doesn't keep unused imports in JS-code.
This breaks because the "agent-base" package is mutating a core nodejs BIF (https) and it does so in a way that is incompatible with how "got" does it's error handling.
I think it's probably a mistake/wrong that agent-base will mutate a core module function in this way, for a workaround back in the nodejs 9.0 days.
Let me link the relevant lines:
https://github.com/TooTallNate/node-agent-base/blob/4.3.0/patch-core.js#L11
The agent-base 4.3.0 looks quite a bit outdated, they're on 6.x which doesn't seem to have this patch in it.
closing this issue as it seems to be resolved by #274 during the past year