Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javascript Exception: TypeError: Cannot read property 'length' of undefined #6623

Open
sentry-io bot opened this issue Feb 9, 2024 · 4 comments
Open

Comments

@sentry-io
Copy link

sentry-io bot commented Feb 9, 2024

Sentry Issue: WORDPRESS-IOS-47HS

Symbolicated Stack Trace

This error is located at:
    in Unknown
    in WithSelect(WithDispatch(f))
    in RCTSafeAreaVi..., stack:
/workdir/gutenberg/packages/editor/src/store/selectors.js:540:<anonymous>
/workdir/gutenberg/packages/data/src/factory.js:52:wrappedSelector
/workdir/gutenberg/packages/editor/src/store/selectors.js:505:isEditedPostSaveable
/workdir/gutenberg/packages/editor/src/store/selectors.native.js:39:<anonymous>
/workdir/gutenberg/packages/data/src/factory.js:52:wrappedSelector
/workdir/gutenberg/packages/data/src/redux-store/index.js:240:boundSelector
/workdir/gutenberg/packages/editor/src/components/autosave-monitor/index.js:110:withSelect$argument_0
/workdir/gutenberg/packages/data/src/components/with-select/index.js:58:mapSelect
/workdir/gutenberg/packages/data/src/components/use-select/index.js:154:registry.__unstableMarkListeningStores$argument_0
/workdir/gutenberg/packages/data/src/registry.js:123:__unstableMarkListeningStores
/workdir/gutenberg/packages/data/src/registry.js:204:<anonymous>
/workdir/gutenberg/packages/data/src/components/use-select/index.js:153:updateValue
/workdir/gutenberg/packages/data/src/components/use-select/index.js:203:<anonymous>
/workdir/gutenberg/packages/data/src/components/use-select/index.js:228:useMappingSelect
/workdir/gutenberg/packages/data/src/components/use-select/index.js:317:useSelect
/workdir/gutenberg/packages/data/src/components/with-select/index.js:59:pure$argument_0
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:3525:renderWithHooks
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:4491:updateFunctionComponent
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7850:beginWork$1
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7304:performUnitOfWork
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7297:workLoopSync
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7279:renderRootSync
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6975:performSyncWorkOnRoot
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:2145:flushSyncCallbacks
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6650:scheduleUpdateOnFiber
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:3767:forceStoreRerender
/workdir/gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:3752:subscribe$argument_0
/workdir/gutenberg/packages/data/src/components/use-select/index.js:89:onStoreChange
/workdir/gutenberg/packages/data/src/components/use-select/index.js:96:onChange
/workdir/gutenberg/packages/data/src/registry.js:247:currentSubscribe$argument_0
/workdir/gutenberg/packages/data/src/redux-store/index.js:351:store.subscribe$argument_0
/workdir/gutenberg/node_modules/redux/lib/redux.js:304:dispatch
/workdir/gutenberg/packages/data/src/redux-store/thunk-middleware.js:7:<anonymous>
/workdir/gutenberg/packages/redux-routine/src/index.js:24:<anonymous>
/workdir/gutenberg/packages/data/src/promise-middleware.js:20:<anonymous>
/workdir/gutenberg/packages/data/src/resolvers-cache-middleware.js:45:<anonymous>
/workdir/gutenberg/packages/data/src/redux-store/index.js:224:Proxy$argument_1.apply
/workdir/gutenberg/packages/core-data/src/actions.js:446:<anonymous>
/workdir/gutenberg/packages/data/src/redux-store/thunk-middleware.js:4:<anonymous>
/workdir/gutenberg/packages/redux-routine/src/index.js:24:<anonymous>
/workdir/gutenberg/packages/data/src/promise-middleware.js:20:<anonymous>
/workdir/gutenberg/packages/data/src/resolvers-cache-middleware.js:45:<anonymous>
/workdir/gutenberg/packages/data/src/redux-store/index.js:204:<anonymous>
/workdir/gutenberg/packages/editor/src/store/actions.js:363:<anonymous>
/workdir/gutenberg/packages/data/src/redux-store/thunk-middleware.js:4:<anonymous>
/workdir/gutenberg/packages/redux-routine/src/index.js:24:<anonymous>
/workdir/gutenberg/packages/data/src/promise-middleware.js:20:<anonymous>
/workdir/gutenberg/packages/data/src/resolvers-cache-middleware.js:45:<anonymous>
/workdir/gutenberg/packages/data/src/redux-store/index.js:204:<anonymous>
/workdir/gutenberg/packages/data/src/components/use-dispatch/use-dispatch-with-map.js:53:<anonymous>
/workdir/gutenberg/node_modules/react-native/Libraries/vendor/emitter/EventEmitter.js:105:emit
/workdir/gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:427:__callFunction
/workdir/gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:__guard$argument_0
/workdir/gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:__guard
/workdir/gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:callFunctionReturnFlushedQueue
Raw stack trace:
RCTFatalException: Unhandled JS Exception: TypeError: Cannot read property 'length' of undefined

This error is located at:
    in Unknown
    in WithSelect(WithDispatch(f))
    in RCTSafeAreaView
    in RCTView
    in Unknown
    in Unknown
    in _
  ...: Unhandled JS Exception: TypeError: Cannot read property 'length' of undefined

This error is located at:
    in Unknown
    in WithSelect(WithDispatch(f))
    in RCTSafeAreaVi..., stack:
anonymous@1:3864753
s@1:1638058
V@1:3861414
anonymous@1:3858150
s@1:1638058
o@1:1616319
anonymous@1:3938767
anonymous@1:1648165
anonymous@1:1649007
__unstableMarkListeningStores@1:1611211
anonymous@1:1611414
M@1:1648740
anonymous@1:1648648
b@1:1649689
anonymous@1:1649831
anonymous@1:1648096
Or@1:387360
Ol@1:393601
Ma@1:427604
zi@1:414609
Ri@1:414511
Pi@1:414395
ki@1:411895
xt@1:377020
hi@1:409372
nl@1:389264
anonymous@1:389158
c@1:1649285
o@1:1649310
anonymous@1:1610140
anonymous@1:1617138
b@1:1620217
anonymous@1:1639904
anonymous@1:1623257
anonymous@1:1639195
anonymous@1:1639494
apply@1:1616662
anonymous@1:3260023
anonymous@1:1639920
anonymous@1:1623257
anonymous@1:1639195
anonymous@1:1639494
anonymous@1:1616059
anonymous@1:3932520
anonymous@1:1639920
anonymous@1:1623257
anonymous@1:1639195
anonymous@1:1639494
anonymous@1:1616059
anonymous@1:1654436
value@1:167672
value@1:171857
anonymous@1:170357
value@1:171303
value@1:170315

  ?, in RCTFatal
  ?, in -[RCTExceptionsManager reportFatal:stack:exceptionId:extraDataAsJSON:]
  ?, in -[RCTExceptionsManager reportException:]
  ?, in -[RCTModuleMethod invokeWithBridge:module:arguments:]
  ?, in facebook::react::invokeInner
...
(14 additional frame(s) were not displayed)
@fluiddot
Copy link
Contributor

fluiddot commented Feb 9, 2024

Based on the breadcrumbs of the Sentry event, I saw that right before the crash the user tapped on editor-undo-button. I wonder if the error is related to the undo/redo logic.

@derekblank
Copy link
Contributor

I wonder if the error is related to the undo/redo logic.

This is plausible, as the stack trace points to the store selectors logic. However, on the line the symbolicated stack trace references, there is no property length:

if ( typeof record.content !== 'function' ) {
	return ! record.content;
}

@fluiddot Could you verify that the stack trace was symbolicated correctly and you produce the same symbolication result? I symbolicated it against iOS and v1.111.2.

Also nothing that there is still only one report of this issue.

@fluiddot
Copy link
Contributor

@fluiddot Could you verify that the stack trace was symbolicated correctly and you produce the same symbolication result? I symbolicated it against iOS and v1.111.2.

@derekblank The symbolization seems correct. The line referenced in the first entry points to access to the length property. You'd need to check the source code in the context of the GB version 1.111.2:

https://github.com/WordPress/gutenberg/blob/rnmobile/1.111.2/packages/editor/src/store/selectors.js#L540

This is the code that seems producing the crash in the selector isEditedPostEmpty:

if ( blocks.length === 0 ) {
	return true;
}

@derekblank
Copy link
Contributor

You'd need to check the source code in the context of the GB version 1.111.2

Yep, makes sense. I was checking trunk. 🤦 Thanks for confirming!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants