尝试设置一个可以访问我的雪花实例的节点/快速端点。
我已经完成了以下操作,它在一个简单的节点文件中工作,但在放入我的应用程序时会中断:
import snowflake from 'snowflake-sdk';
const connection = snowflake.createConnection({
account: 'ACCOUNT',
username: 'USER',
password: 'PW'
});
let connection_ID;
connection.connect(function(err, conn) {
if (err) {
console.error('Unable to connect: ' + err.message);
} else {
console.log('Successfully connected to Snowflake.');
// Optional: store the connection ID.
connection_ID = conn.getId();
var statement = connection.execute({
sqlText: 'SELECT V:city FROM "SNOWFLAKE_SAMPLE_DATA"."WEATHER"."DAILY_14_TOTAL" LIMIT 10',
complete: function(err, stmt, rows) {
if (err) {
console.error('Failed to execute statement due to the following error: ' + err.message);
} else {
console.log('Successfully executed statement: ' + stmt.getSqlText());
console.log(rows);
}
}
});
}
});
这会导致以下错误:
{
"error": {
"path": "",
"message": "Unsupported type: object at: (shallow)"
},
"level": "error",
"message": "uncaughtException: Unsupported type: object at: (shallow)\nError: Unsupported type: object at: (shallow)\n at Reporter.error (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/reporter.js:76:11)\n at new EncoderBuffer (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js:86:21)\n at EncoderBuffer.<anonymous> (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js:70:16)\n at Array.map (<anonymous>)\n at new EncoderBuffer (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js:68:24)\n at DERNode.createEncoderBuffer [as _createEncoderBuffer] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:477:10)\n at DERNode.encode [as _encodeValue] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:545:20)\n at DERNode.encode [as _encode] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:485:21)\n at DERNode.encode [as _encodeValue] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:500:30)\n at DERNode.encode [as _encode] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:485:21)\n at CertID.encode (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/encoders/der.js:22:20)\n at Entity.encode (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/api.js:60:32)\n at Object.exports.buildCertId (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/cert_util.js:83:36)\n at OcspResponseCache.get (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/ocsp_response_cache.js:169:29)\n at getOcspResonseAndVerify (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:314:45)\n at validateCert (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:358:3)\n at eachCallback (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:220:5)\n at validateCertChain (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:253:5)\n at TLSSocket.validate (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:88:7)\n at TLSSocket.emit (events.js:187:15)\n at TLSSocket.EventEmitter.emit (domain.js:442:20)\n at TLSSocket._finishInit (_tls_wrap.js:631:8)",
"stack": "Error: Unsupported type: object at: (shallow)\n at Reporter.error (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/reporter.js:76:11)\n at new EncoderBuffer (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js:86:21)\n at EncoderBuffer.<anonymous> (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js:70:16)\n at Array.map (<anonymous>)\n at new EncoderBuffer (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js:68:24)\n at DERNode.createEncoderBuffer [as _createEncoderBuffer] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:477:10)\n at DERNode.encode [as _encodeValue] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:545:20)\n at DERNode.encode [as _encode] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:485:21)\n at DERNode.encode [as _encodeValue] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:500:30)\n at DERNode.encode [as _encode] (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js:485:21)\n at CertID.encode (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/encoders/der.js:22:20)\n at Entity.encode (/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/api.js:60:32)\n at Object.exports.buildCertId (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/cert_util.js:83:36)\n at OcspResponseCache.get (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/ocsp_response_cache.js:169:29)\n at getOcspResonseAndVerify (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:314:45)\n at validateCert (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:358:3)\n at eachCallback (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:220:5)\n at validateCertChain (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:253:5)\n at TLSSocket.validate (/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js:88:7)\n at TLSSocket.emit (events.js:187:15)\n at TLSSocket.EventEmitter.emit (domain.js:442:20)\n at TLSSocket._finishInit (_tls_wrap.js:631:8)",
"exception": true,
"date": "Wed Jun 02 2021 19:20:07 GMT-0400 (Eastern Daylight Time)",
"process": {
"pid": 3675,
"uid": 503,
"gid": 20,
"cwd": "/Users/test/code/myApp",
"execPath": "/Users/test/.nvm/versions/node/v10.12.0/bin/node",
"version": "v10.12.0",
"argv": ["node", "/Users/test/code/myApp/src/worker-server/index.js"],
"memoryUsage": {
"rss": 154824704,
"heapTotal": 143810560,
"heapUsed": 102881480,
"external": 21753537
}
},
"os": {
"loadavg": [6.28125, 11.08203125, 11.08056640625],
"uptime": 291134
},
"trace": [{
"column": 11,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/reporter.js",
"function": "Reporter.error",
"line": 76,
"method": "error",
"native": false
}, {
"column": 21,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js",
"function": "new EncoderBuffer",
"line": 86,
"method": null,
"native": false
}, {
"column": 16,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js",
"function": null,
"line": 70,
"method": null,
"native": false
}, {
"column": null,
"file": null,
"function": "Array.map",
"line": null,
"method": "map",
"native": false
}, {
"column": 24,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/buffer.js",
"function": "new EncoderBuffer",
"line": 68,
"method": null,
"native": false
}, {
"column": 10,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js",
"function": "DERNode.createEncoderBuffer [as _createEncoderBuffer]",
"line": 477,
"method": "createEncoderBuffer [as _createEncoderBuffer]",
"native": false
}, {
"column": 20,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js",
"function": "DERNode.encode [as _encodeValue]",
"line": 545,
"method": "encode [as _encodeValue]",
"native": false
}, {
"column": 21,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js",
"function": "DERNode.encode [as _encode]",
"line": 485,
"method": "encode [as _encode]",
"native": false
}, {
"column": 30,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js",
"function": "DERNode.encode [as _encodeValue]",
"line": 500,
"method": "encode [as _encodeValue]",
"native": false
}, {
"column": 21,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/base/node.js",
"function": "DERNode.encode [as _encode]",
"line": 485,
"method": "encode [as _encode]",
"native": false
}, {
"column": 20,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/encoders/der.js",
"function": "CertID.encode",
"line": 22,
"method": "encode",
"native": false
}, {
"column": 32,
"file": "/Users/test/code/myApp/node_modules/asn1.js/lib/asn1/api.js",
"function": "Entity.encode",
"line": 60,
"method": "encode",
"native": false
}, {
"column": 36,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/cert_util.js",
"function": "Object.exports.buildCertId",
"line": 83,
"method": "buildCertId",
"native": false
}, {
"column": 29,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/ocsp_response_cache.js",
"function": "OcspResponseCache.get",
"line": 169,
"method": "get",
"native": false
}, {
"column": 45,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js",
"function": "getOcspResonseAndVerify",
"line": 314,
"method": null,
"native": false
}, {
"column": 3,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js",
"function": "validateCert",
"line": 358,
"method": null,
"native": false
}, {
"column": 5,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js",
"function": "eachCallback",
"line": 220,
"method": null,
"native": false
}, {
"column": 5,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js",
"function": "validateCertChain",
"line": 253,
"method": null,
"native": false
}, {
"column": 7,
"file": "/Users/test/code/myApp/node_modules/snowflake-sdk/lib/agent/socket_util.js",
"function": "TLSSocket.validate",
"line": 88,
"method": "validate",
"native": false
}, {
"column": 15,
"file": "events.js",
"function": "TLSSocket.emit",
"line": 187,
"method": "emit",
"native": false
}, {
"column": 20,
"file": "domain.js",
"function": "TLSSocket.EventEmitter.emit",
"line": 442,
"method": "emit",
"native": false
}, {
"column": 8,
"file": "_tls_wrap.js",
"function": "TLSSocket._finishInit",
"line": 631,
"method": "_finishInit",
"native": false
}]
}
最奇怪的是,如果我重新加载了一堆页面,它最终会起作用。然而,这完全不可靠。
我在这里尝试了所有解决方案,但无济于事,包括直接安装 asn1 并添加到 package.json 分辨率: https ://github.com/snowflakedb/snowflake-connector-nodejs/issues/16