如何在 React App 中 运行 AWS 调用尝试次数超过错误?
How to Run AWS in React App Without Call Tries Exceeded Error?
我正在尝试构建一个 React phone 应用程序,它在启动后连接到 AWS。我第一次 运行 使用 Expo 的应用程序时,我收到了一个关于缺少模块“Util”的错误,所以我按照这个单独的 to resolve that issue. Afterwards, I got another issue regarding "filesys.existsSync is not a function," so I followed this other 来解决这个问题。
当我关注第二个线程时,我通过 websocket 协议连接客户端,而不是使用证书。进行这些更改后,我测试了 node.js 文件中的连接是否有效,并且连接没有任何问题。我还可以确认 React 应用程序在没有 AWS 代码的情况下在 Expo 上运行没有错误。但是,一旦我尝试将两者结合起来,我就会得到以下 error.
在 Expo 中,我收到以下错误记录:
03:10
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]: io[8441:0x9b1a90] 57166 ms: Mark-sweep 1387.9 (1429.3) -> 1386.5 (1430.8) MB, 3232.4 / 0.0 ms (+ 145.9 ms in 119 steps since start of marking, biggest step 11.0 ms, walltime since start of marking 3448 ms) (average mu = 0.081, current mu = 0.022) alloca[8441:0x9b1a90] 60040 ms: Mark-sweep 1392.7 (1431.3) -> 1389.5 (1433.8) MB, 2729.3 / 0.0 ms (+ 77.2 ms in 95 steps since start of marking, biggest step 10.8 ms, walltime since start of marking 2867 ms) (average mu = 0.056, current mu = 0.025) allocati
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x74ec865452b]
transform[stdout]: Security context: 0x058c7e02ee11 <JSObject>
transform[stdout]: 1: /* anonymous */ [0xf6ddf9ef2c1] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/index.js:~75] [pc=0x74ec8b3ce6b](this=0x22bfe78ae6e9 <JSFunction traverse (sfi = 0x114f116c781)>,node=0x1467dbf20a49 <Node map = 0x1701e8edb8b1>,opts=0x1a7553733ca1 <Object map = 0x1b9c346b8861>,scope=0x3b66a58da481 <Scope map = 0x1b...
transform[stdout]:
INFO
03:10
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:10
transform[stderr]: 1: 0x7fcaeea2d46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 2: 0x7fcaeea2d4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 3: 0x7fcaeec59e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 4: 0x7fcaeec5a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 5: 0x7fcaeeff4c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 6: 0x7fcaef006043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 7: 0x7fcaef006930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 8: 0x7fcaef00891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 9: 0x7fcaef008975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 10: 0x7fcaeefd4dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 11: 0x7fcaef26031e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x74ec865452b
INFO
03:11
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [8496:0x16dfa90] 64912 ms: Scavenge 1383.0 (1422.8) -> 1382.7 (1423.3) MB, 7.6 / 0.0 ms (average mu = 0.141, current mu = 0.013) allocation failure
transform[stdout]: [8496:0x16dfa90] 67294 ms: Mark-sweep 1383.4 (1423.3) -> 1383.1 (1423.3) MB, 2377.6 / 0.0 ms (average mu = 0.080, current mu = 0.007) allocation failure scavenge might not succeed
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x276fc0c5452b]
transform[stdout]: Security context: 0x04399ea2ee11 <JSObject>
transform[stdout]: 1: visitQueue [0x343848f072f9] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/context.js:~94] [pc=0x276fc0f33dec](this=0x0d7bc0a5b659 <TraversalContext map = 0x97d5ee8c759>,queue=0x0d7bc0a5b6e9 <JSArray[1]>)
transform[stdout]: 2: /* anonymous */ [0x591909657f9] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_module...
transform[stdout]:
INFO
03:11
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:11
transform[stderr]: 1: 0x7fc5340fd46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 2: 0x7fc5340fd4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 3: 0x7fc534329e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 4: 0x7fc53432a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 5: 0x7fc5346c4c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 6: 0x7fc5346d6043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 7: 0x7fc5346d6930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 8: 0x7fc5346d891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 9: 0x7fc5346d8975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 10: 0x7fc5346a4dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 11: 0x7fc53493031e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x276fc0c5452b
INFO
03:13
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [8506:0x19f2a90] 65990 ms: Mark-sweep 1386.5 (1434.8) -> 1384.5 (1437.3) MB, 2579.9 / 0.0 ms (average mu = 0.135, current mu = 0.007) allocation failure scavenge might not succeed
transform[stdout]: [8506:0x19f2a90] 68515 ms: Mark-sweep 1390.3 (1437.3) -> 1387.8 (1455.8) MB, 2511.2 / 0.0 ms (average mu = 0.075, current mu = 0.005) allocation failure scavenge might not succeed
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x21440d25452b]
transform[stdout]: Security context: 0x151eda32ee11 <JSObject>
transform[stdout]: 1: new NodePath [0x91e8a7e4669] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/path/index.js:~59] [pc=0x21440d4a75b7](this=0x3afbd5beda71 <NodePath map = 0x15f88580ba49>,hub=0x048270b825d9 <undefined>,parent=0x251db6f78119 <Node map = 0x15f885836291>)
transform[stdout]: 2: ConstructFrame [pc: 0x21440d199dc9]
transform[stdout]: 3: /* anonymous...
transform[stdout]:
INFO
03:13
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:13
transform[stderr]: 1: 0x7fa28e94d46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 2: 0x7fa28e94d4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 3: 0x7fa28eb79e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 4: 0x7fa28eb7a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 5: 0x7fa28ef14c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 6: 0x7fa28ef26043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 7: 0x7fa28ef26930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 8: 0x7fa28ef2891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 9: 0x7fa28ef28975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 10: 0x7fa28eef4dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 11: 0x7fa28f180424 v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x21440d25452b
INFO
03:14
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [8516:0x902a90] 68473 ms: Scavenge 1380.1 (1421.3) -> 1379.8 (1421.8) MB, 4.9 / 0.0 ms (average mu = 0.101, current mu = 0.033) allocation failure
transform[stdout]: [8516:0x902a90] 68482 ms: Scavenge 1380.5 (1421.8) -> 1380.2 (1422.8) MB, 4.9 / 0.0 ms (average mu = 0.101, current mu = 0.033) allocation failure
transform[stdout]: [8516:0x902a90] 68490 ms: Scavenge 1380.8 (1422.8) -> 1380.5 (1423.3) MB, 4.8 / 0.0 ms (average mu = 0.101, current mu = 0.033) allocation failure
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x6609d5d452b]
transform[stdout]: Security context: 0x1c8f4932ee11 <JSObject>
transform[stdout]: 1: /* anonymous */ [0xb2a7406f381] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/index.js:~75] [pc=0x6609d8687ab](this=0x3d6b1fee0e11 <JSFunction traverse (sfi = 0xbd7d0dec4d1)>,node=0x3f1c1c2c8599 <Node map = 0x3a29e80b98e1>,opts=0x3d6b1fee6479 <Object map = 0x3a29e80ae201>,scope=0x26e2353f0af9 <Scope map = 0x3a...
transform[stdout]:
INFO
03:14
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:14
transform[stderr]: 1: 0x7f2ebd76d46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 2: 0x7f2ebd76d4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 3: 0x7f2ebd999e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 4: 0x7f2ebd99a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 5: 0x7f2ebdd34c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 6: 0x7f2ebdd46043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 7: 0x7f2ebdd46930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 8: 0x7f2ebdd4891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 9: 0x7f2ebdd48975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 10: 0x7f2ebdd14dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 11: 0x7f2ebdfa031e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x6609d5d452b
似乎 aws-sdk 中的某些东西正在进行某种不断失败的调用,因此它一直在重试进行该调用,直到超过它可以重试调用的次数。我不确定这会是什么或为什么会发生,但我们将不胜感激!下面是我的 App.js 文件。
import React, {Component} from 'react';
import { Button, Dimensions, StatusBar, StyleSheet, Text, TextInput, Platform, View, Image } from 'react-native';
import VerticalViewPager from 'react-native-vertical-view-pager/src/component/VerticalViewPager';
import { NavigationContainer } from '@react-navigation/native';
import Test from './Test.js';
import Car from './Car.js';
import Menu from './Menu.js';
import Charging from './Charging.js';
import Aws from 'aws-sdk/dist/aws-sdk-react-native';
import awsIot from 'aws-iot-device-sdk';
import './shim.js';
const AWS_REGION = 'us-east-2';
const AWS_COGNITO_IDENTITY_POOL = 'us-east-2:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
const AWS_IOT_ENDPOINT = 'XXXXXXXXXXXX.iot.us-east-2.amazonaws.com';
Aws.config.region = AWS_REGION
Aws.config.credentials = new Aws.CognitoIdentityCredentials({
IdentityPoolId: AWS_COGNITO_IDENTITY_POOL
})
export default class App extends React.Component {
constructor(props) {
super(props);
this.IotConnect();
}
IoTConnect() {
Aws.config.credentials.get(() => {
const config = {}
let client
config.host = AWS_IOT_ENDPOINT
config.protocol = 'wss'
config.clientId = `client-${Math.floor((Math.random() * 100000) + 1)}`
config.accessKeyId = 'XXXXXXXXXXXXXX';
config.secretKey = 'XXXXXXXXXXXXXXXXXXX';
config.sessionToken = Aws.config.credentials.sessionToken
client = awsIot.device(config)
client.on('connect', () => {
console.log("Successful connection");
})
client.on('error', error => {
console.log(error)
})
})
}
render() {
return (
<NavigationContainer>
<VerticalViewPager showsVerticalScrollIndicator={false}>
<Test></Test>
<Car></Car>
<Menu></Menu>
<Charging></Charging>
</VerticalViewPager>
</NavigationContainer>
);
}
}
折腾了半天,总算是找到了问题所在。无论出于何种原因,expo/React 不喜欢导入 import Aws from 'aws-sdk/dist/aws-sdk-react-native';
,因此我改为将其更改为 import Aws from 'aws-sdk'
。即使更改了导入,我仍然可以调用 Aws.config
,因此无需对代码进行重大更改。我还将以下代码块移动到 IoTConnect
函数中:
Aws.config.credentials = new Aws.CognitoIdentityCredentials({
IdentityPoolId: AWS_COGNITO_IDENTITY_POOL
})
我不确定这是否会影响运行,但安全总比后悔好。
我注意到这个问题只发生在 import Aws from 'aws-sdk/dist/aws-sdk-react-native';
导入中,这表明它由于某种原因破坏了应用程序。我假设导入被反复调用,直到堆中没有任何 space。
我正在尝试构建一个 React phone 应用程序,它在启动后连接到 AWS。我第一次 运行 使用 Expo 的应用程序时,我收到了一个关于缺少模块“Util”的错误,所以我按照这个单独的
当我关注第二个线程时,我通过 websocket 协议连接客户端,而不是使用证书。进行这些更改后,我测试了 node.js 文件中的连接是否有效,并且连接没有任何问题。我还可以确认 React 应用程序在没有 AWS 代码的情况下在 Expo 上运行没有错误。但是,一旦我尝试将两者结合起来,我就会得到以下 error.
在 Expo 中,我收到以下错误记录:
03:10
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]: io[8441:0x9b1a90] 57166 ms: Mark-sweep 1387.9 (1429.3) -> 1386.5 (1430.8) MB, 3232.4 / 0.0 ms (+ 145.9 ms in 119 steps since start of marking, biggest step 11.0 ms, walltime since start of marking 3448 ms) (average mu = 0.081, current mu = 0.022) alloca[8441:0x9b1a90] 60040 ms: Mark-sweep 1392.7 (1431.3) -> 1389.5 (1433.8) MB, 2729.3 / 0.0 ms (+ 77.2 ms in 95 steps since start of marking, biggest step 10.8 ms, walltime since start of marking 2867 ms) (average mu = 0.056, current mu = 0.025) allocati
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x74ec865452b]
transform[stdout]: Security context: 0x058c7e02ee11 <JSObject>
transform[stdout]: 1: /* anonymous */ [0xf6ddf9ef2c1] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/index.js:~75] [pc=0x74ec8b3ce6b](this=0x22bfe78ae6e9 <JSFunction traverse (sfi = 0x114f116c781)>,node=0x1467dbf20a49 <Node map = 0x1701e8edb8b1>,opts=0x1a7553733ca1 <Object map = 0x1b9c346b8861>,scope=0x3b66a58da481 <Scope map = 0x1b...
transform[stdout]:
INFO
03:10
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:10
transform[stderr]: 1: 0x7fcaeea2d46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 2: 0x7fcaeea2d4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 3: 0x7fcaeec59e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 4: 0x7fcaeec5a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 5: 0x7fcaeeff4c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 6: 0x7fcaef006043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 7: 0x7fcaef006930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 8: 0x7fcaef00891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 9: 0x7fcaef008975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 10: 0x7fcaeefd4dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:10
transform[stderr]: 11: 0x7fcaef26031e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x74ec865452b
INFO
03:11
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [8496:0x16dfa90] 64912 ms: Scavenge 1383.0 (1422.8) -> 1382.7 (1423.3) MB, 7.6 / 0.0 ms (average mu = 0.141, current mu = 0.013) allocation failure
transform[stdout]: [8496:0x16dfa90] 67294 ms: Mark-sweep 1383.4 (1423.3) -> 1383.1 (1423.3) MB, 2377.6 / 0.0 ms (average mu = 0.080, current mu = 0.007) allocation failure scavenge might not succeed
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x276fc0c5452b]
transform[stdout]: Security context: 0x04399ea2ee11 <JSObject>
transform[stdout]: 1: visitQueue [0x343848f072f9] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/context.js:~94] [pc=0x276fc0f33dec](this=0x0d7bc0a5b659 <TraversalContext map = 0x97d5ee8c759>,queue=0x0d7bc0a5b6e9 <JSArray[1]>)
transform[stdout]: 2: /* anonymous */ [0x591909657f9] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_module...
transform[stdout]:
INFO
03:11
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:11
transform[stderr]: 1: 0x7fc5340fd46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 2: 0x7fc5340fd4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 3: 0x7fc534329e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 4: 0x7fc53432a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 5: 0x7fc5346c4c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 6: 0x7fc5346d6043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 7: 0x7fc5346d6930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 8: 0x7fc5346d891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 9: 0x7fc5346d8975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 10: 0x7fc5346a4dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:11
transform[stderr]: 11: 0x7fc53493031e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x276fc0c5452b
INFO
03:13
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [8506:0x19f2a90] 65990 ms: Mark-sweep 1386.5 (1434.8) -> 1384.5 (1437.3) MB, 2579.9 / 0.0 ms (average mu = 0.135, current mu = 0.007) allocation failure scavenge might not succeed
transform[stdout]: [8506:0x19f2a90] 68515 ms: Mark-sweep 1390.3 (1437.3) -> 1387.8 (1455.8) MB, 2511.2 / 0.0 ms (average mu = 0.075, current mu = 0.005) allocation failure scavenge might not succeed
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x21440d25452b]
transform[stdout]: Security context: 0x151eda32ee11 <JSObject>
transform[stdout]: 1: new NodePath [0x91e8a7e4669] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/path/index.js:~59] [pc=0x21440d4a75b7](this=0x3afbd5beda71 <NodePath map = 0x15f88580ba49>,hub=0x048270b825d9 <undefined>,parent=0x251db6f78119 <Node map = 0x15f885836291>)
transform[stdout]: 2: ConstructFrame [pc: 0x21440d199dc9]
transform[stdout]: 3: /* anonymous...
transform[stdout]:
INFO
03:13
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:13
transform[stderr]: 1: 0x7fa28e94d46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 2: 0x7fa28e94d4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 3: 0x7fa28eb79e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 4: 0x7fa28eb7a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 5: 0x7fa28ef14c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 6: 0x7fa28ef26043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 7: 0x7fa28ef26930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 8: 0x7fa28ef2891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 9: 0x7fa28ef28975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 10: 0x7fa28eef4dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:13
transform[stderr]: 11: 0x7fa28f180424 v8::internal::Runtime_AllocateInTargetSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x21440d25452b
INFO
03:14
transform[stdout]:
transform[stdout]: <--- Last few GCs --->
transform[stdout]:
transform[stdout]: [8516:0x902a90] 68473 ms: Scavenge 1380.1 (1421.3) -> 1379.8 (1421.8) MB, 4.9 / 0.0 ms (average mu = 0.101, current mu = 0.033) allocation failure
transform[stdout]: [8516:0x902a90] 68482 ms: Scavenge 1380.5 (1421.8) -> 1380.2 (1422.8) MB, 4.9 / 0.0 ms (average mu = 0.101, current mu = 0.033) allocation failure
transform[stdout]: [8516:0x902a90] 68490 ms: Scavenge 1380.8 (1422.8) -> 1380.5 (1423.3) MB, 4.8 / 0.0 ms (average mu = 0.101, current mu = 0.033) allocation failure
transform[stdout]:
transform[stdout]:
transform[stdout]: <--- JS stacktrace --->
transform[stdout]:
transform[stdout]: ==== JS stack trace =========================================
transform[stdout]:
transform[stdout]: 0: ExitFrame [pc: 0x6609d5d452b]
transform[stdout]: Security context: 0x1c8f4932ee11 <JSObject>
transform[stdout]: 1: /* anonymous */ [0xb2a7406f381] [/mnt/c/Users/aless/Desktop/UMNSVP/freya-app/new_branch/node_modules/@babel/traverse/lib/index.js:~75] [pc=0x6609d8687ab](this=0x3d6b1fee0e11 <JSFunction traverse (sfi = 0xbd7d0dec4d1)>,node=0x3f1c1c2c8599 <Node map = 0x3a29e80b98e1>,opts=0x3d6b1fee6479 <Object map = 0x3a29e80ae201>,scope=0x26e2353f0af9 <Scope map = 0x3a...
transform[stdout]:
INFO
03:14
transform[stderr]: FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
INFO
03:14
transform[stderr]: 1: 0x7f2ebd76d46c node::Abort() [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 2: 0x7f2ebd76d4b5 [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 3: 0x7f2ebd999e6a v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 4: 0x7f2ebd99a0e1 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 5: 0x7f2ebdd34c66 [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 6: 0x7f2ebdd46043 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 7: 0x7f2ebdd46930 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 8: 0x7f2ebdd4891d v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 9: 0x7f2ebdd48975 v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 10: 0x7f2ebdd14dda v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/lib/x86_64-linux-gnu/libnode.so.64]
INFO
03:14
transform[stderr]: 11: 0x7f2ebdfa031e v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/lib/x86_64-linux-gnu/libnode.so.64]
transform[stderr]: 12: 0x6609d5d452b
似乎 aws-sdk 中的某些东西正在进行某种不断失败的调用,因此它一直在重试进行该调用,直到超过它可以重试调用的次数。我不确定这会是什么或为什么会发生,但我们将不胜感激!下面是我的 App.js 文件。
import React, {Component} from 'react';
import { Button, Dimensions, StatusBar, StyleSheet, Text, TextInput, Platform, View, Image } from 'react-native';
import VerticalViewPager from 'react-native-vertical-view-pager/src/component/VerticalViewPager';
import { NavigationContainer } from '@react-navigation/native';
import Test from './Test.js';
import Car from './Car.js';
import Menu from './Menu.js';
import Charging from './Charging.js';
import Aws from 'aws-sdk/dist/aws-sdk-react-native';
import awsIot from 'aws-iot-device-sdk';
import './shim.js';
const AWS_REGION = 'us-east-2';
const AWS_COGNITO_IDENTITY_POOL = 'us-east-2:XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX';
const AWS_IOT_ENDPOINT = 'XXXXXXXXXXXX.iot.us-east-2.amazonaws.com';
Aws.config.region = AWS_REGION
Aws.config.credentials = new Aws.CognitoIdentityCredentials({
IdentityPoolId: AWS_COGNITO_IDENTITY_POOL
})
export default class App extends React.Component {
constructor(props) {
super(props);
this.IotConnect();
}
IoTConnect() {
Aws.config.credentials.get(() => {
const config = {}
let client
config.host = AWS_IOT_ENDPOINT
config.protocol = 'wss'
config.clientId = `client-${Math.floor((Math.random() * 100000) + 1)}`
config.accessKeyId = 'XXXXXXXXXXXXXX';
config.secretKey = 'XXXXXXXXXXXXXXXXXXX';
config.sessionToken = Aws.config.credentials.sessionToken
client = awsIot.device(config)
client.on('connect', () => {
console.log("Successful connection");
})
client.on('error', error => {
console.log(error)
})
})
}
render() {
return (
<NavigationContainer>
<VerticalViewPager showsVerticalScrollIndicator={false}>
<Test></Test>
<Car></Car>
<Menu></Menu>
<Charging></Charging>
</VerticalViewPager>
</NavigationContainer>
);
}
}
折腾了半天,总算是找到了问题所在。无论出于何种原因,expo/React 不喜欢导入 import Aws from 'aws-sdk/dist/aws-sdk-react-native';
,因此我改为将其更改为 import Aws from 'aws-sdk'
。即使更改了导入,我仍然可以调用 Aws.config
,因此无需对代码进行重大更改。我还将以下代码块移动到 IoTConnect
函数中:
Aws.config.credentials = new Aws.CognitoIdentityCredentials({
IdentityPoolId: AWS_COGNITO_IDENTITY_POOL
})
我不确定这是否会影响运行,但安全总比后悔好。
我注意到这个问题只发生在 import Aws from 'aws-sdk/dist/aws-sdk-react-native';
导入中,这表明它由于某种原因破坏了应用程序。我假设导入被反复调用,直到堆中没有任何 space。