Decebal on programming

Nodejs Snowflake Sdk Optimisations for Aws Lambda

☕️ 1 min read

Current setup:

We are using snowflake-promise as a wrapper to snowflake-sdk in an appsync lambda resolver.

Issues with current setup:

  1. Not being able to use a connection pool (results in )
Error [ClientError]: Connection already in progress.
  1. 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"
  1. 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 ?

  1. Making the snowflake-sdk async
  1. 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
  1. OCSP Cache