Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade snowflake-sdk from 1.6.23 to 1.9.2 - Connection.execute fails with axios.request is not a function #730

Closed
melindalimafresh opened this issue Dec 12, 2023 · 7 comments
Assignees
Labels
bug Something isn't working status-triage Issue is under initial triage

Comments

@melindalimafresh
Copy link

Please answer these questions before submitting your issue.
In order to accurately debug the issue this information is required. Thanks!

  1. What version of NodeJS driver are you using?
    1.9.2

  2. What operating system and processor architecture are you using?
    OS: MacOS Ventura 13.5.2
    Chip: Apple M1 Pro

  3. What version of NodeJS are you using?
    (node --version and npm --version)
    v18.17.1

  4. What are the component versions in the environment (npm list)?

├── @azure/[email protected]
├── @azure/[email protected]
├── @azure/[email protected]
├── @azure/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @babel/[email protected]
├── @envelop/[email protected]
├── @fast-csv/[email protected]
├── @godaddy/[email protected]
├── @graphql-codegen/[email protected]
├── @graphql-codegen/[email protected]
├── @graphql-codegen/[email protected]
├── @graphql-tools/[email protected]
├── @graphql-tools/[email protected]
├── @jest-mock/[email protected]
├── @jest/[email protected]
├── @octokit/[email protected]
├── @sentry/[email protected]
├── @sentry/[email protected]
├── @sentry/[email protected]
├── @supercharge/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @types/[email protected]
├── @typescript-eslint/[email protected]
├── @typescript-eslint/[email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
└── [email protected]

5.Server version:* E.g. 1.90.1
You may get the server version by running a query:

SELECT CURRENT_VERSION();
  1. What did you do?
  • Updated Snowflake-sdk version from 1.6.23 to 1.9.2
  • yarn build && yarn install
  • Create the Snowflake pool with createPool.
  • Call execute with SQL parameters CREATE DATABASE IF NOT EXISTS fails with the error below.
TypeError: axios.request is not a function

      at NodeHttpClient.sendRequest (node_modules/snowflake-sdk/lib/http/base.js:41:21)
  1. What did you expect to see?

I expected this to create the db and not fail due to an axios import issue.

  1. Can you set logging to DEBUG and collect the logs?

    https://community.snowflake.com/s/article/How-to-generate-log-file-on-Snowflake-connectors

e.g
Add this to get standard output.

var snowflake = require('snowflake-sdk');
snowflake.configure(
{
  logLevel: 'trace'
});
  1. What is your Snowflake account identifier, if any? (Optional)
@melindalimafresh melindalimafresh added the bug Something isn't working label Dec 12, 2023
@github-actions github-actions bot changed the title Upgrade snowflake-sdk from 1.6.23 to 1.9.2 fails with axios.request is not a function SNOW-989519: Upgrade snowflake-sdk from 1.6.23 to 1.9.2 fails with axios.request is not a function Dec 12, 2023
@melindalimafresh melindalimafresh changed the title SNOW-989519: Upgrade snowflake-sdk from 1.6.23 to 1.9.2 fails with axios.request is not a function Upgrade snowflake-sdk from 1.6.23 to 1.9.2 - Connection.execute fails with axios.request is not a function Dec 12, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka self-assigned this Dec 12, 2023
@sfc-gh-dszmolka sfc-gh-dszmolka added the status-triage Issue is under initial triage label Dec 12, 2023
@sfc-gh-dszmolka
Copy link
Collaborator

thank you for submitting this issue; we'll take a look.

@sfc-gh-dszmolka
Copy link
Collaborator

sfc-gh-dszmolka commented Dec 12, 2023

i'm using following script to try and reproduce the issue:

# cat pool.js 
var  snowflake = require('snowflake-sdk');

console.log(`\nNode.js process version is: ${process.version}\n`);

snowflake.configure({ logLevel : 'trace'});

const account = process.env.SFACCOUNT;
const username = process.env.SFUSER;
const password = process.env.SFPASS;
const warehouse = process.env.SFWH;
const application = 'Test-GH-730';

const poolSize = 3;

const pool = snowflake.createPool(
    {
      account: account,
      password: password,
      username: username,
      warehouse: warehouse,
      application: application,
      timeout: 30_000,
    },
    {
      evictionRunIntervalMillis: 30_000,
      idleTimeoutMillis: 30_000,
      max: poolSize,
      min: 1,
    },
  );

pool.use(async (clientConnection) =>
{
    const statement = await clientConnection.execute({
        sqlText: 'CREATE DATABASE IF NOT EXISTS GH730;',
        complete: function (err, stmt, rows)
        {
            var stream = stmt.streamRows();
            stream.on('data', function (row)
            {
                console.log(row);
            });
            stream.on('end', function (row)
            {
                console.log('All rows consumed');
            });
        }
    });
})
;

with axios 1.6.0 (by default 1.6.2 is installed)

# npm list axios
node@ /node
+-- [email protected]
`-- [email protected]
  `-- [email protected] deduped

# npm list
node@ /node
+-- [email protected]
+-- [email protected]
`-- [email protected]

edit --> in your npm list output, snowflake-sdk is at 1.9.1, but you reported issue against snowflake-sdk 1.9.2, can you please confirm which version you're having problem with ?

and looks to be executing correctly to me:

# node pool.js 

Node.js process version is: v18.16.1

{"level":"DEBUG","message":"[6:36:26.406 AM]: 300"}
{"level":"DEBUG","message":"[6:36:26.415 AM]: Contacting SF: /session/v1/login-request?requestId=[..], (1/7)"}
..
{ status: 'Database GH730 successfully created.' }
All rows consumed

with no error whatsoever.

base.js was indeed recently fixed with 1.9.2 (#713) but I'm wondering how you can get to the error.

would it be please possible to send a runnable reproduction which when executed leads to the issue you're seeing? this would be very helpful in debugging. thank you in advance !

edit installed the same modules from your npm list and my test script still runs correctly, so it would really be important to have a reproduction which throws the error for you.

@sfc-gh-dszmolka sfc-gh-dszmolka added the status-information_needed Additional information is required from the reporter label Dec 12, 2023
@sscraigie
Copy link

sscraigie commented Dec 12, 2023

I think i got a similar error:

ReferenceError: request is not defined
     at NodeHttpClient.sendRequest (webpack-internal:///(rsc)/./node_modules/snowflake-sdk/lib/http/base.js:32:17)

@sfc-gh-dszmolka
Copy link
Collaborator

Until now, the issue does not reproduce for me yet, but I would really love to take a look at it, so if anyone is able to create a reproducible scenario; please do share - thank you in advance !

@Satevg
Copy link

Satevg commented Dec 15, 2023

Not sure if it's related, but after update from 1.6.x to 1.9.2, we've got failed tests:

Summary of all failing tests
 FAIL  src/common/services/SnowflakeService.spec.ts
  ● Test suite failed to run

    Jest encountered an unexpected token

    Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.

    Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.

    By default "node_modules" folder is ignored by transformers.

    Here's what you can do:
     • If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
     • If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
     • To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
     • If you need a custom transformation specify a "transform" option in your config.
     • If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.

    You'll find more details and examples of these config options in the docs:
    https://jestjs.io/docs/configuration
    For information about custom transformations, see:
    https://jestjs.io/docs/code-transformation

    Details:

    /home/satevg/Dev/aquicore/microservices/node_modules/snowflake-sdk/node_modules/axios/index.js:1
    ({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import axios from './lib/axios.js';

@sfc-gh-dszmolka
Copy link
Collaborator

tried following scenario as well.

  1. install axios 1.6.0
  2. install [email protected]
# npm why axios
[email protected]
node_modules/axios
  axios@"^1.6.0" from the root project

[email protected]
node_modules/snowflake-sdk/node_modules/axios
  axios@"^0.27.2" from [email protected]
  node_modules/snowflake-sdk
    snowflake-sdk@"^1.6.23" from the root project
  1. run above test script, confirm it works
  2. install [email protected]
# npm why axios
[email protected]
node_modules/axios
  axios@"^1.6.0" from the root project
  axios@"^1.6.0" from [email protected]
  node_modules/snowflake-sdk
    snowflake-sdk@"^1.9.2" from the root project
  1. run above test scripts again. still works

probably something is broken ,but until now i'm unable to reproduce and get to the same issue.

But since it is broken for at least for 3 of you guys unfortunately - if any of you happens to have any closer details besides the fact it breaks for you after upgrade, that would be really helpful.

@sfc-gh-dszmolka
Copy link
Collaborator

issue seems to be not generically fitting for all use cases and there has been no reproducible scenario for a long while. i'm now going to mark this issue as closed for now but in case any of you can share a reproduction scenario which leads to this issue, kindly do so and we can investigate further.

@sfc-gh-dszmolka sfc-gh-dszmolka removed the status-information_needed Additional information is required from the reporter label Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status-triage Issue is under initial triage
Projects
None yet
Development

No branches or pull requests

4 participants