AWS Lambda Error: Failed to load gRPC binary module because it was not installed for the current system - firebase

I have problem with AWS Lambda function deployment with Serverless Framework. I use #google-cloud-firestore npm package which requires grpc package.
Function execution throws error:
{
"errorMessage": "Failed to load gRPC binary module because it was not installed for the current system\nExpected directory: node-v48-linux-x64-glibc\nFound: [node-v59-darwin-x64-unknown]\nThis problem can often be fixed by running \"npm rebuild\" on the current system\nOriginal error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'",
"errorType": "Error",
"stackTrace": [
"Found: [node-v48-linux-x64-unknown]",
"This problem can often be fixed by running \"npm rebuild\" on the current system",
"Original error: Cannot find module '/var/task/node_modules/grpc/src/node/extension_binary/node-v48-linux-x64-glibc/grpc_node.node'",
"Object.<anonymous> (/var/task/node_modules/grpc/src/grpc_extension.js:44:17)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)",
"Object.<anonymous> (/var/task/node_modules/grpc/src/client.js:38:12)",
"Module._compile (module.js:570:32)",
"Object.Module._extensions..js (module.js:579:10)",
"Module.load (module.js:487:32)",
"tryModuleLoad (module.js:446:12)",
"Function.Module._load (module.js:438:3)",
"Module.require (module.js:497:17)",
"require (internal/module.js:20:19)"
]
}
So, as I understood, lambda requires grps built with target node-v48-linux-x64-glibc
Typing npm i -S grpc --target=6.4.0 --target_arch=x64 --target_platform=linux has only changed node-v59-darwin-x64-unknown to node-v48-linux-x64-unknown.
How can I change unknown to glibc?
Any help would be really appreciated!

Fix
Basically, you need to specify the target of the grcp library.
Copied from that link:
{
"main": "index.js",
"scripts": {
"postinstall": "npm rebuild grpc --target=6.1.0 --target_arch=x64 --target_platform=linux --target_libc=glibc"
}
}

I got something similar to work by including a --target_libc=glibc, found in the documentation for node-pre-gyp.

Related

Firebase functions deploy 403 Permission denied on 'locations/null' error

I am trying to deploy Firebase functions project, on two different target projects on Firebase. One is in region "us-cenral" and the other one is "europe-west".
I'm using only functions and RTDB from Firebase, I don't have a need for "hosting".
At the start, I was having only one Firebase project region:"us-central" and I was able to deploy functions without problem. I have created another project recently in region:"europe-west" on the same billing account. And also in the local project I have added that another project using command:
firebase use --add project2
Since I didn't deploy functions for a couple of months and there was no need to check if deployment is still working on "project1" I have not checked if this functionally is working.
After adding "project2" I have issued command to deploy for the first time on another region.
When using command: "firebase deploy --only functions"
command ended with the following error:
There was an issue deploying your functions. Verify that your project has a Google App Engine instance setup at https://console.cloud.google.com/appengine and try again. If this issue persists, please contact support.
! functions: Upload Error: HTTP Error: 403, Permission denied on 'locations/null' (or it may not exist).
Error: HTTP Error: 403, Permission denied on 'locations/null' (or it may not exist).
[2022-05-11T19:32:17.580Z] Error Context: {
"body": {
"error": {
"code": 403,
"message": "Permission denied on 'locations/null' (or it may not exist).",
"status": "PERMISSION_DENIED"
}
},
"response": {
"statusCode": 403
}
}
Switching back to project1 and trying to deploy the same thing, I got the same error.
So now I'm stuck. Does anyone have experience with this problem and how to overcome it.
Google support suggest to create "App Engine application", I cannot see how this can help as I didn't had that thing in the 1st place and everything was working. Now with the second project I have this error that suggest permissions problem. Since I have OWNER account on both of these projects what could be wrong?
What I have done so far:
installed the latest firebase tools (same problem)
defined default region on both projects (as stated above)
checked that I'm logged with the OWNER account (also switched between different owner account but the same issue)
checked permissions and din't find anything useful
default service accounts exist on both projects with rights
visited suggested link: https://console.cloud.google.com/appengine
on both projects (and still have the same error although not sure if I need to deploy?!? - I don't have anything there to deploy or do I?)
Config package.json:
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"engines": {
"node": "10"
},
"dependencies": {
"canvas": "^2.6.1",
"firebase-admin": "^10.2.0",
"firebase-functions": "^3.21.0",
"jsbarcode": "^3.11.0",
"qrcode": "^1.4.4"
},
"devDependencies": {
"eslint": "^5.16.0",
"eslint-plugin-promise": "^4.0.1",
"firebase-functions-test": "^0.2.0"
},
"private": true
}
Configuration didn't changed from the 1st deploy to project1 when everything was working fine.
At the end I found out the reason for my problem, and posting just to help the others if they end up with the same error.
The problem was not deployment script "per se" but the function that was connected to fetch data from RTDB on the project. Method "region" was supposed to get configured "region(fnRegion)" value, but that variable value was "null" and resulted with the error posted above during deployment.
function selectDatabaseReference(path = '/') {
return functions
.region(fnRegion) // Sets function region
.database
.ref(path); // Sets database reference path
}
It would be nice if I could get more descriptive error to the real cause of the error (I'm not truly sure, what would be the content of that error message though).
Anyway it's good I was not able to deploy functions because of this.

Google Cloud Function / Firebase Function deployment stops working: "unexpected end of file"

Deploying our Firebase Function suddenly stopped working recently. Running firebase functions:log provided an insight that was not very helpful:
2022-02-15T06:53:12.421579Z E XXX:
{"#type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"Build
failed: curl: (22) The requested URL returned error: 404 \n\ngzip:
stdin: unexpected end of file\ntar: Child returned status 1\ntar:
Error is not recoverable: exiting now; Error ID:
08522105"},"authenticationInfo":{"principalEmail":"XXXX"},"serviceName":"cloudfunctions.googleapis.com","methodName":"google.cloud.functions.v1.CloudFunctionsService.UpdateFunction","resourceName":"XXXX"}
The deployment works fine for other projects, but fails even for older versions of this project (ones that have been deployed successfully in the past).
I received a 404 error from gcloud.functions.deploy on deploy:
Deploying function (may take a while - up to 2 minutes)...
.
For Cloud Build Stackdriver Logs, visit: https://console.cloud.google.com/logs/viewer?project=x-xxx-dev&advancedFilter=resource.type%3Dbuild%0Aresource.labels.build_id%3D35aac420-xx-4cd1-b7be-blah%0AlogName%3Dprojects%2Fxxx-xxx-dev%2Flogs%2Fcloudbuild
................failed.
ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Build failed: curl: (22) The requested URL returned error: 404
The root cause error is not visible here, but if you click on the Stackdriver logs link in the console output, there will be more details. In my case, the root error was that yarn 2.4.3 couldn't be downloaded # https://github.com/yarnpkg/yarn/releases/download/v2.4.3/yarn-v2.4.3.tar.gz
I did not expect to be using yarn 2 (berry) at this point, but in my package.json I was not explicit:
"engines": {
...
"yarn": ">=1.22.0"
},
By changing to accept only version 1, the problem was resolved:
"engines": {
...
"yarn": "^1.22.0"
},
I still don't understand why npm resolved this missing version.
The firebase log was not useful at all, but since Functions are built using "Google Cloud Build" I was able to get more insight into what's wrong by opening the Logs Explorer in Google Cloud Console. Select the resource type "Cloud Build" and there you will find logs of each build step and which one failed.
In this case, it fails to fetch the yarn-version specific in our package.json (1.22). Changing it to "1.22.17" (latest as of now) fixed the build.
"engines": {
"node": "14",
"npm": "8.1",
"yarn": "1.22.17"
},

Vague error in Vercel deployment (exit with code 1)

So normally Vercel gives me decent error messages, but this one seems to have no detail. Just
"failed with exit code 1".
For context, I just started this project w the basic NextJS template, made a few modifications, and this is my first deploy.
Failed once and I assumed it was because NextJS has strict type checking on by default, so I modified the next.config.js file as follows (per here):
module.exports = {
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
};
But still failed. Here is the full log:
10:23:27.575 Cloning github.com/lawderp/physical (Branch: main, Commit: 8f97554)
10:23:28.589 Cloning completed: 1.014s
10:23:28.614 Analyzing source code...
10:23:29.739 Installing build runtime...
10:23:31.612 Build runtime installed: 1.873s
10:23:34.043 Looking up build cache...
10:23:34.164 Build cache found. Downloading...
10:23:35.100 Build cache downloaded [21.48 MB]: 936.007ms
10:23:36.250 Installing dependencies...
10:23:36.489 yarn install v1.22.11
10:23:36.547 [1/4] Resolving packages...
10:23:36.734 success Already up-to-date.
10:23:36.743 Done in 0.26s.
10:23:36.754 Detected Next.js version: 11.1.2
10:23:36.755 Running "yarn run build"
10:23:37.021 yarn run v1.22.11
10:23:37.047 $ next build
10:23:37.820 info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
10:23:37.976 info - Skipping validation of types...
10:23:40.439 error Command failed with exit code 1.
10:23:40.439 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
10:23:40.456 Error: Command "yarn run build" exited with 1
Still not sure what the issue was but eventually figured out how to get past this - ignored ESLint during build by adding the following to next.config.js:
eslint: {
ignoreDuringBuilds: true,
},
(I don't advise doing this but this was quick low-stakes experiment)
I received the same vague message after making eslint alterations. Locally linting and deployment was successful, however deploying to vercel failed like yours.
Although "ignoreDuringBuilds": "true" in my .eslint.json did band-aid fix the issue, I was able to rollback each eslint change and found that my "linebreak-style": ["error", "windows"] was the underlying issue.
It passed linting locally, but failed on vercel deployment. I've fixed my line-breaks and all works great now without having to ignore during builds.

Deployment error. Build failed: src/index.js does not exist;

This drives me crazy - I'm getting the below error during firebase deploy (click the image to enlarge):
package.json
{
"engines": {
"node": "10"
},
"main": "src/index.js",
...
}
The index.js does exist under the src folder.
I tried to change the path in "main" to a fake path and then it fails before deployment which is expected.
However with the "main": "src/index.js" it actually starts to deploy and fails much later during the process as shown on the screenshot above.
What am I missing here?
I'm using firebase-tools v8.12.0
Please, check build steps and your functions configuration in firebase.json.

Impossible to install SQLite on React Native project

I'd like to start a new React Native project including SQLite Storagee.
I've already done this before so I know that it should work, but not today...
So I've init a new project in which I installed react-native-sqlite-storage following this step by step tutorial (https://www.npmjs.com/package/react-native-sqlite-storage), the android part.
Everything is fine untill I run my project whith react-native run-android.
Here is my package.json file
{
"name": "pokedex",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.8.6",
"react-native": "0.60.5",
"react-native-sqlite-storage": "^4.0.0"
},
"devDependencies": {
"#babel/core": "^7.5.5",
"#babel/runtime": "^7.5.5",
"#react-native-community/eslint-config": "^0.0.5",
"babel-jest": "^24.9.0",
"eslint": "^6.2.2",
"jest": "^24.9.0",
"metro-react-native-babel-preset": "^0.56.0",
"react-test-renderer": "16.8.6"
},
"jest": {
"preset": "react-native"
}
}
Here is the result in my terminal. I don't understand what's going on.
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :react-native-sqlite-storage.
Required by:
project :app
> Unable to find a matching configuration of project :react-native-sqlite-storage:
- None of the consumable configurations have attributes.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
error Failed to install the app. Make sure you have the Android development environment set up: https://facebook.github.io/react-native/docs/getting-started.html#android-development-environment. Run CLI with --verbose flag for more details.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':app:preDebugBuild'.
> Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not resolve project :react-native-sqlite-storage.
Required by:
project :app
> Unable to find a matching configuration of project :react-native-sqlite-storage:
- None of the consumable configurations have attributes.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 10s
at checkExecSyncError (child_process.js:629:11)
at execFileSync (child_process.js:647:13)
at runOnAllDevices (/home/axel/leclercq.axel#gmail.com/Pokedex/Developpement - AXEL ONLY/V5/pokedex/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:74:39)
at buildAndRun (/home/axel/leclercq.axel#gmail.com/Pokedex/Developpement - AXEL ONLY/V5/pokedex/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:158:41)
at then.result (/home/axel/leclercq.axel#gmail.com/Pokedex/Developpement - AXEL ONLY/V5/pokedex/node_modules/#react-native-community/cli-platform-android/build/commands/runAndroid/index.js:125:12)
at process._tickCallback (internal/process/next_tick.js:68:7)
I've tried it with various version of both react-native and sqlite-storage but nothing works.
Need help please
Hey I found the solution!
Just go to your settings.gradle file and change
THIS LINE
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/src/android')
TO THIS
project(':react-native-sqlite-storage').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sqlite-storage/platforms/android')
Greetings!
Same problem :(
Could not determine the dependencies of task ':app:preDebugBuild'.
Could not resolve all task dependencies for configuration ':app:debugRuntimeClasspath'.
Could not resolve project :react-native-sqlite-storage.
Required by:
project :app
Unable to find a matching configuration of project :react-native-sqlite-storage: None of the consumable configurations have attributes.
React Native also requires Java SE Development Kit (JDK). I installed it and then just restarted the program and the error was resolved. Hopefully this works for you as well!!
Greetings.

Resources