shopify-api-js
shopify-api-js copied to clipboard
unable to deploy firebase function when importing v3.0.1 or later
Issue summary
When you import the @shopify/shopify-api package into a node firebase function, it will fail to deploy with the following error:
Error: SQLITE_CANTOPEN: unable to open database file
Expected behavior
You should be able to deploy using this package.
Actual behavior
When you deploy code that imports the @shopify/shopify-api package in a firebase function to the cloud, the function fails to deploy at the point where the function is invoked to make sure that it is properly deployed. When this happens, the function crashes with the error Error: SQLITE_CANTOPEN: unable to open database file
.
This happens when using versions 3.0.1 or above. 3.0.0 is not affected and deploys fine.
The error seems to have something to do with files not being found.
Steps to reproduce the problem
- Create a firebase function (https://firebase.google.com/docs/functions/get-started)
- Deploy the function to the cloud and verify that the function works
- Now import the @shopify/shopify-api package into your function and use it in some way
- Deploy the function to the cloud -- function will fail to deploy
- Downgrade your @shopify/shopify-api package to 3.0.0
- Deploy the function to the cloud and it will succeed
Reduced test case
Checklist
- [x] I have described this issue in a way that is actionable (if possible)
same issue here: https://github.com/Shopify/shopify-node-api/issues/389
@surma please revert the changes of v3.1.0 that making SQLite a peer-deps of session storage (https://github.com/Shopify/shopify-node-api/blob/main/src/context.ts#L46)
Receiving a similar issue when attempting to deploy to AWS Lambda via Serverless Framework after upgrading from 3.0.1 to 3.1.0:
⠹ Packaging (0s)
✘ [ERROR] Could not resolve "mock-aws-s3"
../../node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
43 │ const AWSMock = require('mock-aws-s3');
╵ ~~~~~~~~~~~~~
You can mark the path "mock-aws-s3" as external to exclude it from the bundle, which will remove
this error. You can also surround this "require" call with a try/catch block to handle this
failure at run-time instead of bundle-time.
✘ [ERROR] Could not resolve "nock"
../../node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
112 │ const nock = require('nock');
╵ ~~~~~~
You can mark the path "nock" as external to exclude it from the bundle, which will remove this
error. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "pg-native"
../../node_modules/pg/lib/native/client.js:4:21:
4 │ var Native = require('pg-native')
╵ ~~~~~~~~~~~
You can mark the path "pg-native" as external to exclude it from the bundle, which will remove
this error. You can also surround this "require" call with a try/catch block to handle this
failure at run-time instead of bundle-time.
I’ll look into this.
Can you share with me what Session storage module you are using? Can you find where your code calls Shopify.Context.initialize({...})
and tell me what (if any) value you set for SESSION_STORAGE
?
I have the same issue when using AWS Lambda with Serverless Stack framework after upgrading from 3.0.1 to 3.1.0. Same error as above:
✘ [ERROR] Could not resolve "mock-aws-s3"
node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:43:28:
43 │ const AWSMock = require('mock-aws-s3');
╵ ~~~~~~~~~~~~~
You can mark the path "mock-aws-s3" as external to exclude it from the bundle, which will remove
this error. You can also surround this "require" call with a try/catch block to handle this
failure at run-time instead of bundle-time.
✘ [ERROR] Could not resolve "nock"
node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:112:23:
112 │ const nock = require('nock');
╵ ~~~~~~
You can mark the path "nock" as external to exclude it from the bundle, which will remove this
error. You can also surround this "require" call with a try/catch block to handle this failure at
run-time instead of bundle-time.
✘ [ERROR] Could not resolve "pg-native"
node_modules/pg/lib/native/client.js:4:21:
4 │ var Native = require('pg-native')
╵ ~~~~~~~~~~~
You can mark the path "pg-native" as external to exclude it from the bundle, which will remove
this error. You can also surround this "require" call with a try/catch block to handle this
failure at run-time instead of bundle-time.
Appreciate your help on this please
I'm facing same issue with AWS lambda. I'm using custom session storage with dynamo db.
It may be fixed by #393. I'll waiting the release of the pull.
- error log
{
"errorType": "Error",
"errorMessage": "SQLITE_CANTOPEN: unable to open database file",
"code": "SQLITE_CANTOPEN",
"errno": 14,
"stack": [
"Error: SQLITE_CANTOPEN: unable to open database file"
]
}
-
Shopify.Context.initialize({...})
Shopify.Context.initialize({
API_KEY,
API_SECRET_KEY,
SCOPES,
HOST_NAME: host,
HOST_SCHEME,
IS_EMBEDDED_APP,
SESSION_STORAGE: new Shopify.Session.CustomSessionStorage(
this.mySessionStore.store.bind(this.mySessionStore),
this.mySessionStore.load.bind(this.mySessionStore),
this.mySessionStore.delete.bind(this.mySessionStore)
),
API_VERSION: ApiVersion.January22,
});
Having exactly same issue with 3.1.3. But I have added those modules as external modules (assuming these are needed on dev only) in lambda bundling and the error is gone. But now I am getting this error
externalModules: ['aws-sdk', 'mock-aws-s3', 'nock'],
This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.
We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.
If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines
Thank you!