Nodejs Snowflake Sdk Optimisations for Aws Lambda
• • ☕️ 1 min readCurrent setup:
We are using snowflake-promise as a wrapper to snowflake-sdk in an appsync lambda resolver.
Issues with current setup:
- Not being able to use a connection pool (results in )
Error [ClientError]: Connection already in progress.
- OCP Cache
Reading OCSP cache file. /home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json"
Failed to read OCSP cache file: /home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json, err: Error: ENOENT: no such file or directory, open '/home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json'\n at Object.openSync (fs.js:498:3)\n at Object.readFileSync (fs.js:394:35)\n at new OcspResponseCache (/var/task/webpack:/node_modules/snowflake-promise/node_modules/snowflake-sdk/lib/agent/ocsp_response_cache.js:79:1)\n at getOcspResponseCache (/var/task/webpack:/node_modules/snowf"
Contact OCSP Cache Server: http://ocsp.snowflakecomputing.com/ocsp_response_cache.json"
Finish OCSP Cache Server: http://ocsp.snowflakecomputing.com/ocsp_response_cache.json"
/home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json"
Writing OCSP cache file. /home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json"
Failed to update OCSP cache file: /home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json, err: Error: ENOENT: no such file or directory, open '/home/sbx_user1051/.cache/snowflake/ocsp_response_cache.json'\n at Object.openSync (fs.js:498:3)\n at Object.writeFileSync (fs.js:1529:35)\n at OcspResponseCache.resetCacheStatus (/var/task/webpack:/node_modules/snowflake-promise/node_modules/snowflake-sdk/lib/agent/ocsp_response_cache.js:138:1)\n at /var/task/webpack:/node_modules/snowflake"
- Npm package is not up to date (Last publish: a year ago) and snowflake sdk’s latest updates are not available as a couple of different forks have tried to signal
Has anyone tried to solve these issues before ?
- Making the snowflake-sdk async
- Using a connection Pool
- snowflake-promise fork
- an open PR has suggested using a
isUp
method, which I merged on the fork above, but it did not make a difference in my case - I tried using a Connection Pool, which worked well for our case
- OCSP Cache
- can be be turned off
- HOW TO: TURN OFF OCSP CHECKING IN SNOWFLAKE CLIENT DRIVERS
- having the check happen on each request is rather useless, following these best practices should mitigate and eliminate the need for the OCSP check