oblador / react-native-esbuild

Fast bundler and dev server for react-native using esbuild
MIT License
592 stars 11 forks source link

JavaScript heap out of memory on esbuild-bundle or start with MONOREPO env. #21

Closed Kida007 closed 2 years ago

Kida007 commented 2 years ago

setted up react-native-esbuild on our app and after proper configuration . it crashes with a fatal error while bundling or starting a dev server.

Here is the configuration:

// react-native.config.js
const {babelPlugin, createEsbuildCommands} = require('react-native-esbuild');
const alias = require('esbuild-plugin-alias');
const path = require('path');

// See https://esbuild.github.io/api/#simple-options
const commands = createEsbuildCommands((config) => ({
  ...config,
  plugins: config.plugins.concat(
    babelPlugin({
      filter: /(node_modules\/react-native-reanimated)\/.+\.[tj]sx?$/,
    }),
    alias({
      crypto: require.resolve(
        __dirname,
        '../../node_modules/react-native-quick-crypto',
      ),
      buffer: require.resolve(
        '../../node_modules/@craftzdog/react-native-buffer',
      ),
      stream: require.resolve(
        __dirname,
        '../../node_modules/stream-browserify',
      ),
      fs: require.resolve(__dirname, '../../node_modules/react-native-fs'),
      path: require.resolve(__dirname, '../../node_modules/path-browserify'),
    }),
  ),
}));

module.exports = {
  project: {
    ios: {},
    android: {},
  },
  assets: ['src/assets/fonts'],
  commands,
};

Unfortunately i cannot create repro repo since this belong to an org. would really appreciate some pointers. here is The Error StackTrace:

Error / Crash Report ``` <--- Last few GCs ---> [54594:0x148008000] 25224 ms: Scavenge 4052.5 (4133.7) -> 4044.9 (4133.5) MB, 4.3 / 0.0 ms (average mu = 0.302, current mu = 0.256) allocation failure [54594:0x148008000] 25231 ms: Scavenge 4053.3 (4134.5) -> 4046.8 (4134.5) MB, 4.5 / 0.0 ms (average mu = 0.302, current mu = 0.256) allocation failure [54594:0x148008000] 26898 ms: Mark-sweep 4055.7 (4136.9) -> 4045.0 (4135.2) MB, 1662.1 / 0.0 ms (average mu = 0.213, current mu = 0.123) allocation failure scavenge might not succeed <--- JS stacktrace ---> FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory 1: 0x104d782dc node::Abort() [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 2: 0x104d78464 node::errors::TryCatchScope::~TryCatchScope() [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 3: 0x104ec7b90 v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 4: 0x104ec7b24 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 5: 0x10504b23c v8::internal::Heap::GarbageCollectionReasonToString(v8::internal::GarbageCollectionReason) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 6: 0x10504e84c v8::internal::Heap::CollectSharedGarbage(v8::internal::GarbageCollectionReason) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 7: 0x10504ba04 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 8: 0x10504932c v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 9: 0x1050550a4 v8::internal::Heap::AllocateRawWithLightRetrySlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 10: 0x105055138 v8::internal::Heap::AllocateRawWithRetryOrFailSlowPath(int, v8::internal::AllocationType, v8::internal::AllocationOrigin, v8::internal::AllocationAlignment) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 11: 0x105027fcc v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationType, v8::internal::AllocationOrigin) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 12: 0x1053600d0 v8::internal::Runtime_AllocateInYoungGeneration(int, unsigned long*, v8::internal::Isolate*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 13: 0x10567474c Builtins_CEntry_Return1_DontSaveFPRegs_ArgvOnStack_NoBuiltinExit [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 14: 0x10a18905c 15: 0x10a18b2e0 16: 0x1056874c8 Builtins_ArrayForEach [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 17: 0x1056083d8 Builtins_InterpreterEntryTrampoline [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 18: 0x1056083d8 Builtins_InterpreterEntryTrampoline [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 19: 0x10a109698 20: 0x10a013164 21: 0x10a079464 22: 0x105639bac Builtins_GeneratorPrototypeNext [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 23: 0x109ed4acc 24: 0x105639bac Builtins_GeneratorPrototypeNext [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 25: 0x109e98294 26: 0x109ea0b7c 27: 0x109e99dd8 28: 0x109ea8f08 29: 0x109eb13ec 30: 0x109ea8228 31: 0x109e9861c 32: 0x109ea0b7c 33: 0x109e99dd8 34: 0x109ef40bc 35: 0x1056bc878 Builtins_PromiseFulfillReactionJob [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 36: 0x105629db4 Builtins_RunMicrotasks [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 37: 0x1056060a4 Builtins_JSRunMicrotasksEntry [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 38: 0x104fd79ec v8::internal::(anonymous namespace)::Invoke(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 39: 0x104fd7e20 v8::internal::(anonymous namespace)::InvokeWithTryCatch(v8::internal::Isolate*, v8::internal::(anonymous namespace)::InvokeParams const&) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 40: 0x104fd7f0c v8::internal::Execution::TryRunMicrotasks(v8::internal::Isolate*, v8::internal::MicrotaskQueue*, v8::internal::MaybeHandle*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 41: 0x104ffab48 v8::internal::MicrotaskQueue::RunMicrotasks(v8::internal::Isolate*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 42: 0x104ffb3dc v8::internal::MicrotaskQueue::PerformCheckpoint(v8::Isolate*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 43: 0x104cc5db4 node::InternalCallbackScope::Close() [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 44: 0x104cc57c4 node::InternalCallbackScope::~InternalCallbackScope() [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 45: 0x104d7449c node::fs::FSReqPromise >::Reject(v8::Local) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 46: 0x104d7cc6c node::fs::FSReqAfterScope::Reject(uv_fs_s*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 47: 0x104d7cefc node::fs::AfterOpenFileHandle(uv_fs_s*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 48: 0x1055e6764 uv__work_done [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 49: 0x1055e9f00 uv__async_io [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 50: 0x1055fbc78 uv__io_poll [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 51: 0x1055ea390 uv_run [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 52: 0x104cc6ccc node::SpinEventLoop(node::Environment*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 53: 0x104db16e0 node::NodeMainInstance::Run(int*, node::Environment*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 54: 0x104db13ac node::NodeMainInstance::Run(node::EnvSerializeInfo const*) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 55: 0x104d4b2e0 node::Start(int, char**) [/Users/piyushgupta-me/.nvm/versions/node/v16.15.1/bin/node] 56: 0x109a35088 fatal error: all goroutines are asleep - deadlock! /bin/sh: line 1: 54594 Abort trap: 6 react-native esbuild-bundle --bundle-output ./build/index.bundle --assets-dest ./build goroutine 1 [semacquire]: sync.runtime_Semacquire(0x140000021a0?) runtime/sema.go:62 +0x28 sync.(*WaitGroup).Wait(0x1400010a2d8) sync/waitgroup.go:139 +0x80 main.runService(0x1) github.com/evanw/esbuild/cmd/esbuild/service.go:177 +0x3e0 main.main() github.com/evanw/esbuild/cmd/esbuild/main.go:214 +0x1a0 goroutine 6 [chan receive]: main.runService.func1() github.com/evanw/esbuild/cmd/esbuild/service.go:110 +0x4c created by main.runService github.com/evanw/esbuild/cmd/esbuild/service.go:108 +0x14c goroutine 7 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ab0c660}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.runService.func2() github.com/evanw/esbuild/cmd/esbuild/service.go:132 +0x38 created by main.runService github.com/evanw/esbuild/cmd/esbuild/service.go:129 +0x264 goroutine 8 [chan receive]: github.com/evanw/esbuild/internal/bundler.(*scanner).scanAllDependencies(0x1400031c400) github.com/evanw/esbuild/internal/bundler/bundler.go:1656 +0x198 github.com/evanw/esbuild/internal/bundler.ScanBundle({_, _, _, _, _, _}, {_, _}, {_, _}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:1138 +0x5a0 github.com/evanw/esbuild/pkg/api.rebuildImpl({0x2, 0x4, 0x0, 0x140002802a0, 0x0, {0x1400029000e, 0x3c}, 0x0, 0x3, {0x0, ...}, ...}, ...) github.com/evanw/esbuild/pkg/api/api_impl.go:1066 +0x1608 github.com/evanw/esbuild/pkg/api.buildImpl({0x2, 0x4, 0x0, 0x140002802a0, 0x0, {0x1400029000e, 0x3c}, 0x0, 0x3, {0x0, ...}, ...}) github.com/evanw/esbuild/pkg/api/api_impl.go:799 +0x46c github.com/evanw/esbuild/pkg/api.Build(...) github.com/evanw/esbuild/pkg/api/api.go:364 main.(*serviceType).handleBuildRequest(0x1400010a2c0, 0x0?, 0x14000280000?) github.com/evanw/esbuild/cmd/esbuild/service.go:501 +0x7e4 main.(*serviceType).handleIncomingPacket(0x0?, {0x14000181800?, 0x0?, 0x0?}) github.com/evanw/esbuild/cmd/esbuild/service.go:232 +0x124 main.runService.func3() github.com/evanw/esbuild/cmd/esbuild/service.go:163 +0x30 created by main.runService github.com/evanw/esbuild/cmd/esbuild/service.go:162 +0x3f4 goroutine 4952 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f170}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x14015eaef50, 0x6d}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14015eaef50, 0x6d}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x14014bd2460?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4701 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f140}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x14006a7c000, 0x8b}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14006a7c000, 0x8b}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x140074d5d10?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 5116 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f0b0}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x1401562fa40, 0x67}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1401562fa40, 0x67}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x140150c9810?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 555 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ade3c50}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.3({{0x14014e1ba80, 0x1d}, {0x1400190ac40, 0x6c}, {0x102ac49ae, 0x4}, {0x1400190ac40, _}, _, {_, ...}}) github.com/evanw/esbuild/cmd/esbuild/service.go:781 +0x550 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0x14014e1ba80, 0x1d}, {0x1400190ac40, 0x5f}, {0x0, 0x0}, {{0x1400190ac40, _}, {_, _}, ...}, ...}) github.com/evanw/esbuild/pkg/api/api_impl.go:1625 +0x194 github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x140002be180?, 0x1, 0x4?}, {0x102c4c1d8, 0x1400031c000}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:742 +0x640 github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:406 +0x1a70 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 5112 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1400bfb0e40}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x1400990ca20, 0x81}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400990ca20, 0x81}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1401562e8c0?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4951 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x14008fbdc50}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x1401631f570, 0x6f}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1401631f570, 0x6f}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x14010217b80?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4950 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x14008fbdbf0}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x14015716850, 0x68}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14015716850, 0x68}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x14012347500?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 5115 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f080}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x14016447500, 0x65}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14016447500, 0x65}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1401156b100?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4949 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x14008fbdc20}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x140164470a0, 0x62}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x140164470a0, 0x62}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1401562e1c0?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4845 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ab5d5c0}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.3({{0x1401ab7a9e0, 0x1f}, {0x1401400c3f0, 0x6e}, {0x102ac49ae, 0x4}, {0x1401400c3f0, _}, _, {_, ...}}) github.com/evanw/esbuild/cmd/esbuild/service.go:781 +0x550 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0x1401ab7a9e0, 0x1f}, {0x1401400c3f0, 0x55}, {0x0, 0x0}, {{0x1401400c3f0, _}, {_, _}, ...}, ...}) github.com/evanw/esbuild/pkg/api/api_impl.go:1625 +0x194 github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x140002be180?, 0x1, 0x4?}, {0x102c4c1d8, 0x1400031c000}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:742 +0x640 github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:406 +0x1a70 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4699 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ad61f80}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x140111aa300, 0x7c}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x140111aa300, 0x7c}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1401058a5a0?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4953 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x14008fbdc80}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x1401b000150, 0x65}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1401b000150, 0x65}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1400ef2e900?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4892 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f110}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.3({{0x1400764bd00, 0x21}, {0x1401156ad80, 0x77}, {0x102ac49ae, 0x4}, {0x1401156ad80, _}, _, {_, ...}}) github.com/evanw/esbuild/cmd/esbuild/service.go:781 +0x550 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0x1400764bd00, 0x21}, {0x1401156ad80, 0x55}, {0x0, 0x0}, {{0x1401156ad80, _}, {_, _}, ...}, ...}) github.com/evanw/esbuild/pkg/api/api_impl.go:1625 +0x194 github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x140002be180?, 0x1, 0x4?}, {0x102c4c1d8, 0x1400031c000}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:742 +0x640 github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:406 +0x1a70 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4703 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401afc9da0}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x1400e25a510, 0x81}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400e25a510, 0x81}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x14014a56b60?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 5117 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f050}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x140150009a0, 0x69}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x140150009a0, 0x69}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x140150c85b0?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4702 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401afc9dd0}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x1400e539200, 0x7a}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x1400e539200, 0x7a}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1401154db00?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 5114 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401ae7f020}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x14011714b00, 0x77}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14011714b00, 0x77}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x140103429a0?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 4697 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1401a9edf80}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.3({{0x1401a7f4980, 0x18}, {0x14012fe6850, 0x6b}, {0x102ac49ae, 0x4}, {0x14012fe6850, _}, _, {_, ...}}) github.com/evanw/esbuild/cmd/esbuild/service.go:781 +0x550 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onResolve.func1({{0x1401a7f4980, 0x18}, {0x14012fe6850, 0x55}, {0x0, 0x0}, {{0x14012fe6850, _}, {_, _}, ...}, ...}) github.com/evanw/esbuild/pkg/api/api_impl.go:1625 +0x194 github.com/evanw/esbuild/internal/bundler.RunOnResolvePlugins({0x140002be180?, 0x1, 0x4?}, {0x102c4c1d8, 0x1400031c000}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:742 +0x640 github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:406 +0x1a70 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec goroutine 5113 [chan receive]: main.(*serviceType).sendRequest(0x1400010a2c0, {0x102be5300, 0x1400bfb0e70}) github.com/evanw/esbuild/cmd/esbuild/service.go:203 +0xe8 main.(*serviceType).convertPlugins.func2.4({{0x14011714800, 0x80}, {0x102ac49ae, 0x4}, {0x0, 0x0}, {0x0, 0x0}}) github.com/evanw/esbuild/cmd/esbuild/service.go:860 +0x3b0 github.com/evanw/esbuild/pkg/api.(*pluginImpl).onLoad.func1({{0x0, 0x0}, {{0x14011714800, 0x80}, {0x102ac49ae, 0x4}, {0x0, 0x0}, 0x0}}) github.com/evanw/esbuild/pkg/api/api_impl.go:1680 +0xe4 github.com/evanw/esbuild/internal/bundler.runOnLoadPlugins({0x140002be180?, 0x1, 0x1401562e5b0?}, {0x102c4c1d8, 0x1400031c000}, {0x102c4e1d0, 0x140002a0380?}, 0x0?, {0x140002afb20, 0x1400028a180, ...}, ...) github.com/evanw/esbuild/internal/bundler/bundler.go:859 +0xa0c github.com/evanw/esbuild/internal/bundler.parseFile({{0x102c4e1d0, 0x140002a0380}, {0x140002afb20, 0x1400028a180, 0x1400028a198, 0x14000288260, 0x4, 0x140002806c0}, {0x102c4c1d8, 0x1400031c000}, ...}) github.com/evanw/esbuild/internal/bundler/bundler.go:128 +0x178 created by github.com/evanw/esbuild/internal/bundler.(*scanner).maybeParseFile github.com/evanw/esbuild/internal/bundler/bundler.go:1257 +0x6ec error Command failed with exit code 134. ```
oblador commented 2 years ago

Hi, I would need a reproduction repo to debug this, but one guess i have is that the alias plugin wants the actual file as input, not the directory.

Kida007 commented 2 years ago

i see. thanks for the quickest reply possible. is there any other/better way to polyfill libraries ?

oblador commented 2 years ago

Try adding index.js or whatever is relevant to the end. Think this is the way to go in general 👍

Kida007 commented 2 years ago

Tried adding the relevant entrypoints for each lib. unfortunately same error. even removing the alias completely . it gives me 2 error warnings ( could not resolve crypto, stream ....) , takes some time and then crash with same error. initially i thought it might be due to node 16 + m1 combination, but example app builds just fine.

Thanks for your help though mate, will try reproducing on new project.

Kida007 commented 2 years ago

Tried reproducing this on example project. added all the crytpo libs . but it bundles perfectly for me on example project. btw our project is part of big monorepo architecture, can this be related ?

Kida007 commented 2 years ago

Here are my new findings

a) I was able to successfully bundle when i took the application out of monorepo. hence it looks like a monorepo issue. not sure how to solve it

b) after installing react-native-quick-crypto a JSI based library . their is a runtime error maybe related to bundle. reproducible on example app as well.

E0829 17:50:10.347693 175337472 NativeToJsBridge.cpp:188] Attempting to call JS function on a bad application bundle: RCTDeviceEventEmitter.emit()
Kida007 commented 2 years ago

so found out because of the huge monorepo packages/deps, esbuild build step was kind of going OOM. hence i deleted some packages ( not related to the app ) and build the monorepo again. and then it bundled fine. will change the Issue Title for future reference and close it.

issue i still face

E0829 17:50:10.347693 175337472 NativeToJsBridge.cpp:188] Attempting to call JS function on a bad application bundle: RCTDeviceEventEmitter.emit()