Ionic - Allocation failed - JavaScript heap out of memory - ionic-framework

Im getting some error em I try to build my Ionic app, I've tried a lot of thing but doesnt work.. that is what i tried:
"scripts": {
"clean": "ionic-app-scripts clean",
"build": "node --max-old-space-size=2048 ./node_modules/.bin/ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
"ionic:build": "ionic-app-scripts build",
"ionic:serve": "ionic-app-scripts serve"
},
sudo node --max-old-space-size=4096 /usr/local/bin/ionic cordova build android --prod
sudo node --max-old-space-size=8196 /usr/local/bin/ionic cordova build android --prod
------------------------------- the error :
<--- Last few GCs --->
[6482:0x3d981d0] 295201 ms: Mark-sweep 4034.2 (4143.6) -> 4034.2 (4143.6) MB, 3372.5 / 0.0 ms allocation failure GC in old space requested
[6482:0x3d981d0] 299051 ms: Mark-sweep 4034.2 (4143.6) -> 4034.2 (4127.6) MB, 3848.7 / 0.0 ms last resort GC in old space requested
[6482:0x3d981d0] 302348 ms: Mark-sweep 4034.2 (4127.6) -> 4034.2 (4127.6) MB, 3296.8 / 0.0 ms last resort GC in old space requested
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x3a46b1e0427d]
Security context: 0x30ba8a6206a9 <JSObject>
1: setEmitFlags [/home/kill/Documents/iapp/ioo/ionic/node_modules /#angular-devkit/build-optimizer/node_modules/typescript/lib/typescript.js:~49349] [pc=0x3a46b2e932ba](this=0x368505ba3269 <Object map = 0xbfaea5b5881>,node=0x1a071e0bf419 <IdentifierObject map = 0x1b4dd8085311>,emitFlags=16777216)
2: createEntityNameFromSymbolChain(aka createEntityName...
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
1: node::Abort() [ionic]
2: 0x87b56c [ionic]
3: v8::Utils::ReportOOMFailure(char const*, bool) [ionic]
4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [ionic]
5: v8::internal::Factory::NewByteArray(int, v8::internal::PretenureFlag) [ionic]
6: v8::internal::SourcePositionTableBuilder::ToSourcePositionTable(v8::internal::Isolate*) [ionic]
7: v8::internal::compiler::CodeGenerator::FinalizeCode() [ionic]
8: v8::internal::compiler::PipelineImpl::FinalizeCode() [ionic]
9: v8::internal::compiler::PipelineCompilationJob::FinalizeJobImpl(v8::internal::Isolate*) [ionic]
10: v8::internal::Compiler::FinalizeCompilationJob(v8::internal::CompilationJob*, v8::internal::Isolate*) [ionic]
11: v8::internal::OptimizingCompileDispatcher::InstallOptimizedFunctions() [ionic]
12: v8::internal::StackGuard::HandleInterrupts() [ionic]
13: v8::internal::Runtime_StackGuard(int, v8::internal::Object**, v8::internal::Isolate*) [ionic]
14: 0x3a46b1e0427d
Aborted

Related

Installing React Native Firebase fails at compiling RingBuffer.swift

I am attempting to implement RNFB to my react-native project. for iOS the pods install just fine. However, when I run npm run iOS I get the following error and crash report:
❌ /Users/[Redacted]/Documents/GitHub/[Redacted]/ios/Pods/FirebaseCoreInternal/FirebaseCore/Internal/Sources/HeartbeatLogging/RingBuffer.swift:19:35: reference to generic type 'Array' requires arguments in <...>
case outOfBoundsPush(pushIndex: Array.Index, endIndex: Array.Index)
I was able to find this article that was very recent and it appears to be what I'm looking for but I have absolutely no idea what it says... google translate helps a little bit but I do not know enough to be able to infer a solution.
honestly I do not really even need anything related to heartbeat from firebase. I just need to use the Firebase Analytics and Google Analytics capabilities. But this package came with it and I don't see a way to tell it not to compile.
Regardless, I attempted to downgrade to a lower version of RNFB, I believe I it was version 15.4.0 -> 15.0.0 to see if maybe the new package was the problem but I still get the same errors.
I tried modifying the RingBuffer.swift file... but the file is read-only.
This issue is happening in other FirebaseCore/Internal files...
The following build commands failed:
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
CompileSwift normal x86_64 /Users/[Redacted]/Documents/GitHub/[Redacted]/ios/Pods/FirebaseCoreInternal/[Redacted]/Internal/Sources/HeartbeatLogging/HeartbeatController.swift
CompileSwift normal x86_64 /Users/[Redacted]/Documents/GitHub/[Redacted]/ios/Pods/FirebaseCoreInternal/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsBundle.swift
CompileSwift normal x86_64 /Users/[Redacted]/Documents/GitHub/[Redacted]/ios/Pods/FirebaseCoreInternal/FirebaseCore/Internal/Sources/HeartbeatLogging/HeartbeatsPayload.swift
CompileSwift normal x86_64 /Users/[Redacted]/Documents/GitHub/[Redacted]/ios/Pods/FirebaseCoreInternal/FirebaseCore/Internal/Sources/HeartbeatLogging/RingBuffer.swift
here is my package.json file
"main": "index.js",
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"web": "expo start --web",
"start": "react-native start",
"test": "jest",
"debug-build-android": "react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res",
"build-android": "./android/gradlew ./android/assembleRelease"
},
"dependencies": {
"#react-native-async-storage/async-storage": "^1.13.4",
"#react-native-community/masked-view": "0.1.10",
"#react-native-community/netinfo": "^5.9.9",
"#react-native-firebase/app": "^15.0.0",
"#react-navigation/bottom-tabs": "^5.11.2",
"#react-navigation/drawer": "^5.11.4",
"#react-navigation/native": "^5.8.10",
"#react-navigation/stack": "^5.12.8",
"axios": "^0.21.1",
"expo": "~40.0.0",
"expo-app-loading": "1.0.3",
"expo-asset": "~8.2.1",
"expo-blur": "~8.2.2",
"expo-file-system": "~9.3.0",
"expo-gl": "^9.2.0",
"expo-keep-awake": "~8.4.0",
"expo-screen-orientation": "^3.3.0",
"expo-splash-screen": "~0.8.1",
"expo-three": "^5.5.1",
"expo-updates": "~0.4.0",
"expo-web-browser": "~8.6.0",
"immutability-helper": "^3.1.1",
"lodash.throttle": "^4.1.1",
"react": "16.13.1",
"react-dom": "16.13.1",
"react-native": "~0.63.4",
"react-native-background-downloader": "^2.3.4",
"react-native-base64": "^0.2.1",
"react-native-elements": "3.4.1",
"react-native-fast-image": "^8.3.4",
"react-native-gesture-handler": "~1.8.0",
"react-native-maps": "^0.27.1",
"react-native-reanimated": "~1.13.0",
"react-native-render-html": "^5.0.1",
"react-native-safe-area-context": "^3.1.9",
"react-native-screens": "~2.15.0",
"react-native-toast-message": "1.4.9",
"react-native-unimodules": "~0.12.0",
"react-native-video": "^5.2.0",
"react-native-view-pdf": "^0.13.2",
"react-native-webview": "11.0.0",
"react-native-zip-archive": "^6.0.2",
"react-navigation-header-buttons": "^7.0.1",
"react-redux": "^7.2.2",
"react-three-fiber": "^5.3.21",
"realm": "^10.4.0",
"redux": "^4.0.5",
"redux-devtools-extension": "^2.13.9",
"redux-persist": "^6.0.0",
"redux-thunk": "^2.3.0",
"three": "0.123.0"
},
"devDependencies": {
"#babel/core": "~7.9.0",
"#testing-library/react-native": "^7.2.0",
"#types/jest": "^26.0.19",
"#types/lodash.throttle": "^4.1.6",
"#types/react": "^17.0.0",
"#types/react-native": "^0.63.40",
"#types/react-native-background-downloader": "^2.3.3",
"#types/react-native-base64": "^0.2.0",
"#types/react-native-video": "^5.0.10",
"#types/react-redux": "^7.1.14",
"#types/react-test-renderer": "^17.0.0",
"#types/redux-mock-store": "^1.0.3",
"#types/three": "^0.125.3",
"babel-jest": "^25.2.6",
"jest": "~25.2.6",
"jest-expo": "^42.1.0",
"react-test-renderer": "~16.13.1",
"redux-mock-store": "^1.5.4",
"ts-node": "^10.2.1",
"typescript": "^4.1.3"
},
"jest": {
"preset": "jest-expo"
},
"private": true,
"version": "1.0.1"
}
here is my pod file
$RNFirebaseAsStaticFramework = true #firebase requires static frameworkds
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/react-native-unimodules/cocoapods.rb'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target '[Redacted]' do
use_unimodules!
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
# react native firebase requires frameworks...
use_frameworks!
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
# use_flipper!({ 'Flipper-Folly' => '2.5.3', 'Flipper' => '0.87.0', 'Flipper-RSocket' => '1.3.1' })
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.0'
config.build_settings['SWIFT_VERSION'] = '5.0'
end
end
flipper_post_install(installer)
end
end
Xcode Version : Version 13.4.1 (13F100)
some lines have been removed for anonymity.
I was able to fix this compilation error by overwriting the specified pod dependency .swift file with modifications to the following code block
//dependency errors at this point in the file
case outOfBoundsPush(pushIndex: Array.Index, endIndex: Array.Index)
//adding a type definition for the array fixes compilation error
case outOfBoundsPush(pushIndex: Array<Any>.Index, endIndex: Array<Any>.Index)
now if only I knew where to report the pod file discrepancy. Or if anyone would like to tell me why the pod file is packaged improperly for my compiler to understand?
Firebase's minimum supported Swift Version is 5.3 - so the override in the Podfile's post_install script may be the issue. Try deleting or updating config.build_settings['SWIFT_VERSION'] = '5.0'

devtools: no browser pages found at WDIO REPL Chrome

After starting wdio repl chrome, getting following endless looping with no browser pages found, retrying... and The chrome tab is open but not operational, it means you can not call a url etc. Calling devtool is not possible. Chrome version 95.
Actually there is/are no big chance/s at last days. No browser update, maybe the windows has been automatically updated through company daily/weekly Routine.
$ wdio repl chrome
2021-12-10T11:09:00.101Z INFO devtools:puppeteer: Initiate new session using the DevTools protocol
2021-12-10T11:09:00.102Z INFO devtools: Launch Google Chrome with flags: --enable-automation --disable-popup-blocking --disable-extensions --disable-background-networking --disable-background-timer-throttling --disable-backgrounding-occluded-windows --disable-sync --metrics-recording-only --disable-default-apps --mute-audio --no-first-run --no-default-browser-check --disable-hang-monitor --disable-prompt-on-repost --disable-client-side-phishing-detection --password-store=basic --use-mock-keychain --disable-component-extensions-with-background-pages --disable-breakpad --disable-dev-shm-usage --disable-ipc-flooding-protection --disable-renderer-backgrounding --force-fieldtrials=*BackgroundTracing/default/ --enable-features=NetworkService,NetworkServiceInProcess --disable-features=site-per-process,TranslateUI,BlinkGenPropertyTrees --window-position=0,0 --window-size=1200,900
2021-12-10T11:09:01.206Z INFO devtools: Connect Puppeteer with browser on port 59545
2021-12-10T11:09:02.240Z INFO devtools: no browser pages found, retrying...
2021-12-10T11:09:02.342Z INFO devtools: no browser pages found, retrying...
2021-12-10T11:09:02.442Z INFO devtools: no browser pages found, retrying...
2021-12-10T11:09:02.544Z INFO devtools: no browser pages found, retrying...
my package.json has following configuration
{
"name": "webdriverio",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"wdio:local": "cross-env DEBUG=\"*\" wdio run wdio.local.conf.ts",
"wdio:ci": "wdio run wdio.ci.conf.ts",
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"#types/chai-as-promised": "^7.1.3",
"#wdio/cli": "^7.6.0",
"#wdio/repl": "^7.16.3",
"date-fns": "^2.24.0",
"dayjs": "^1.10.7",
"debug": "^2.6.9",
"log4js": "^6.3.0",
"oracledb": "^5.2.0",
"pdfkit": "^0.12.3",
"string-similarity": "^4.0.4",
"xlsx": "^0.16.9"
},
"devDependencies": {
"#types/debug": "^4.1.7",
"#types/node": "^16.11.7",
"#types/oracledb": "^5.2.1",
"#typescript-eslint/eslint-plugin": "^4.6.1",
"#typescript-eslint/parser": "^4.6.1",
"#wdio/cucumber-framework": "^7.6.0",
"#wdio/devtools-service": "^7.16.10",
"#wdio/local-runner": "^7.6.0",
"axios": "^0.21.1",
"chai": "^4.2.0",
"chai-as-promised": "^7.1.1",
"chromedriver": "^95.0.0",
"cross-env": "^7.0.3",
"eslint": "^7.13.0",
"fs-extra": "^10.0.0",
"multiple-cucumber-html-reporter": "^1.18.0",
"ts-node": "^9.1.1",
"typescript": "^4.2.4",
"wdio-chromedriver-service": "^7.0.0",
"wdio-cucumberjs-json-reporter": "^1.0.0",
"wdio-wait-for": "^2.0.3"
}
}
The #wdio/repl is updated but there is no improvement at the moment.
I don't know what it caused but after a fresh new start of window 10 solved wdio repl chrome problem.

react-native-sensors Error: Native modules for sensors not available. Did react-native link run successfully?

Thanks for any help, getting error message "Error: Native modules for sensors not available. Did react-native link run successfully?" when running npx react-native start
npx react-native run-android gives this error: > Task :app:processDebugManifest FAILED
right after installing react-native-sensors.
Install procedure:
npx react-native init proj8
cd proj8
npm install react-native-sensors --save
npx react-native link react-native-sensors
The last command reported successful but when I went through the manual Android procedure some parts were not done as follows:
import com.sensors.RNSensorsPackage;
was in android/app/src/main/java/[...]/MainApplication.java
new RNSensorsPackage()
was not there, I added as follows:
#Override
protected List<ReactPackage> getPackages() {
#SuppressWarnings("UnnecessaryLocalVariable")
List<ReactPackage> packages = new PackageList(this).getPackages();
// Packages that cannot be autolinked yet can be added manually here, for example:
// packages.add(new MyReactNativePackage());
packages.add(new RNSensorsPackage());
return packages;
}
include ':react-native-sensors'
project(':react-native-sensors').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-sensors/android')
were both there in android/settings.gradle
dependencies {
implementation project(':react-native-sensors')
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
I had to add implementation project(':react-native-sensors')
I don't think my code matters yet but App.js:
import React, {useState, useEffect, useRef} from 'react';
import { StyleSheet,ScrollView,SafeAreaView,Platform, View,Text } from 'react-native';
export default function App() {
var Rndr =
<Text>asdf</Text>
return Rndr
}
package.json:
{
"name": "proj8",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"lint": "eslint ."
},
"dependencies": {
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-sensors": "^7.0.1"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^1.1.0",
"babel-jest": "^25.1.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1"
},
"jest": {
"preset": "react-native"
}
}
I encountered the same problem. This occurs because react-native-sensors has a minsdk version is 17 and react-native's default minsdk version is 16 Its quite easy to solve.
Just go to android/build.gradle
Change minSdkVersion to anything above 17
Before
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
After
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 19
compileSdkVersion = 29
targetSdkVersion = 29
}

How to create a multi-apps project in Ionic 4?

I try to create a simple multi-apps project in Ionic 4, following the ionic documentation, but it doesn't work.
https://ionicframework.com/docs/cli/configuration#multi-app-projects
My config :
Ionic : v4.12.0
Angular CLI : 7.3.8
Node : 10.15.1
npm : 6.9.0
Windows 10
What I have done :
I have created a directory “monorepo”.
In this folder, I created a file ionic.config.json and pasted in it the code below:
{
"projects": {}
}
In monorepo, I create a second directory : apps.
In this directory (with the command prompt), I write the command :
ionic start "app1" --no-deps
monorepo/ionic.config.json is correctly populated with the data:
{
"projects": {
"app1": {
"name": "app1",
"integrations": {},
"type": "angular",
"root": "apps\\app1"
}
}
}
But when I try to serve the server, it won't work.
ionic serve --project app1 return me this error message :
> ng run app1:serve --host=0.0.0.0 --port=8100
[ng] Project 'app1' could not be found in workspace.
[ng] Error: Project 'app1' could not be found in workspace.
[ng] at Workspace.getProject (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\core\src\workspace\workspace.js:93:19)
[ng] at Architect.getBuilderConfiguration (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\node_modules\#angular-devkit\architect\src\architect-legacy.js:117:41)
[ng] at RunCommand.runSingleTarget (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\models\architect-command.js:160:45)
[ng] at RunCommand.runArchitectTarget (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\models\architect-command.js:201:35)
[ng] at RunCommand.run (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\commands\run-impl.js:14:25)
[ng] at RunCommand.validateAndRun (C:\Users\name\AppData\Roaming\npm\node_modules\#angular\cli\models\command.js:124:31)
[ng] at process._tickCallback (internal/process/next_tick.js:68:7)
[ng] at Function.Module.runMain (internal/modules/cjs/loader.js:745:11)
[ng] at startup (internal/bootstrap/node.js:283:19)
[ng] at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)
[ERROR] ng has unexpectedly closed (exit code 1).
The Ionic CLI will exit. Please check any output above for error details.
When I go under the file associated with the error (workspace.js:93:19), and I do console.log, I obtain this info:
getProject(projectName) {
this._assertLoaded();
console.log("this.projectName : " + projectName); // this.projectName : app1
console.log("\n\nthis._workspace.projects : \n");
console.log(this._workspace.projects); // this._workspace.projects : app and app-e2e
const workspaceProject = this._workspace.projects[projectName];
(Values displayed are in comments).
The projectName variable seems ok. But the available project in this._workspace.projects are app and app-e2e which seem weird.
What is my problem ?
What did I miss ?
I managed to compile by replacing in the angular.json every app keyword by the name of my ionic project (here, app1).
{
"$schema": "./node_modules/#angular-devkit/core/src/workspace/workspace-schema.json",
"version": 1,
"defaultProject": "app1", <-- HERE
"newProjectRoot": "projects",
"projects": {
"app1": { <-- HERE
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app1", <-- NOT MANDATORY
"schematics": {},
"architect": {
"build": { ... },
"serve": {
"builder": "#angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "app1:build" <-- HERE
},
...
}
I suppose that instead of putting several angular apps within one project structure you should rewrite each ionic project's angular.json

Scalac compiler doesn't create a .class file

I am trying understand the error handling in scala.
I compiled the code as following
scalac sampleExceptionHandling.sc
I thought it would create a .class file and using javap command, I can look at the equivalent java code. For somereason, .class file isn't created. And no errors thrown either after executing Scalac command.
Any suggestion please?
import java.io.FileReader
import java.io.FileNotFoundException
import java.io.IOException
object Demo {
def main(args: Array[String]) {
try {
val f = new FileReader("input.txt")
} catch {
case ex: FileNotFoundException =>{
println("Missing file exception")
}
case ex: IOException => {
println("IO Exception")
}
}
}
}
It does create .class which is same as your class name not as your filename.
Following is the result of scalac sampleExceptionHandling.sc
$ ll
total 24
10909194 -rw-r--r-- 1 as18 prayagupd 936 Mar 15 10:00 Demo$.class
10909193 -rw-r--r-- 1 as18 prayagupd 565 Mar 15 10:00 Demo.class
10909167 -rw-r--r-- 1 as18 prayagupd 378 Mar 15 09:59 sampleExceptionHandling.sc
To run the class
$ scala Demo
Missing file exception
To see the bytecode,
$ javap -c Demo.class
Compiled from "sampleExceptionHandling.sc"
public final class Demo {
public static void main(java.lang.String[]);
Code:
0: getstatic #16 // Field Demo$.MODULE$:LDemo$;
3: aload_0
4: invokevirtual #18 // Method Demo$.main:([Ljava/lang/String;)V
7: return
}
And,
$ javap -c Demo$.class
Compiled from "sampleExceptionHandling.sc"
public final class Demo$ {
public static final Demo$ MODULE$;
public static {};
Code:
0: new #2 // class Demo$
3: invokespecial #12 // Method "<init>":()V
6: return
public void main(java.lang.String[]);
Code:
0: new #20 // class java/io/FileReader
3: dup
4: ldc #22 // String input.txt
6: invokespecial #25 // Method java/io/FileReader."<init>":(Ljava/lang/String;)V
9: astore 4
11: goto 35
14: astore_2
15: getstatic #30 // Field scala/Predef$.MODULE$:Lscala/Predef$;
18: ldc #32 // String IO Exception
20: invokevirtual #36 // Method scala/Predef$.println:(Ljava/lang/Object;)V
23: goto 35
26: astore_3
27: getstatic #30 // Field scala/Predef$.MODULE$:Lscala/Predef$;
30: ldc #38 // String Missing file exception
32: invokevirtual #36 // Method scala/Predef$.println:(Ljava/lang/Object;)V
35: return
Exception table:
from to target type
0 14 26 Class java/io/FileNotFoundException
0 14 14 Class java/io/IOException
}