wordpress-mobile/gutenberg-mobile

RCTFatalException: Unhandled JS Exception: TypeError: Cannot read property 'getEditWrapperProps' of undefined This error is ...: Unhandled JS Exception: TypeError: Cannot read property 'getEditWrapperProps' of undefined

sentry-io opened this issue · 3 comments

Sentry Issue: JETPACK-IOS-16B9

Symbolicated stack trace

gutenberg/packages/block-editor/src/components/block-list/block.native.js:248:BlockListBlock
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:3525:renderWithHooks
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7743:beginWork$1
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7304:performUnitOfWork
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7297:workLoopSync
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:7279:renderRootSync
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:6975:performSyncWorkOnRoot
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:2145:flushSyncCallbacks
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:8462:batchedUpdatesImpl
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1106:batchedUpdates
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1137:_receiveRootNodeIDEvent
gutenberg/node_modules/react-native/Libraries/Renderer/implementations/ReactNativeRenderer-prod.js:1178:ReactNativePrivateInterface.RCTEventEmitter.register$argument_0.receiveEvent
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:427:__callFunction
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:113:__guard$argument_0
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:368:__guard
gutenberg/node_modules/react-native/Libraries/BatchedBridge/MessageQueue.js:112:callFunctionReturnFlushedQueue

Steps to reproduce it

  • Open the app and go to the Pages screen.
  • Create a blank page.
  • Switch to HTML mode and copy the following HTML code:
<!-- wp:jetpack/paywall /-->
  • Switch back to Visual mode.
  • Save the page.
  • Close the editor and open the page again.
  • Observe the crash.

Sentry event

RCTFatalException: Unhandled JS Exception: TypeError: Cannot read property 'getEditWrapperProps' of undefined

This error is located at:
    in Unknown
    in IfCondition(Component)
    in WithDispatch(IfCondition(Component))
    in Unknown
    in Pure(...: Unhandled JS Exception: TypeError: Cannot read property 'getEditWrapperProps' of undefined

This error is located at:
    in Unknown
    in IfCondition(Component)
    in WithD..., stack:
anonymous@1:3084941
Or@1:384619
Ma@1:425196
zi@1:411868
Ri@1:411770
Pi@1:411654
ki@1:409154
xt@1:374279
Ce@1:425569
Ne@1:367422
Me@1:367695
receiveEvent@1:420135
value@1:169131
anonymous@1:167631
value@1:168577
value@1:167589

  ?, 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)

The first time I spotted this crash was when checking JavaScript exceptions in version 23.7-rc-1 of the Jetpack Android app (reference).

I was able to reproduce this on both platforms following the steps above, but it seems like a rare circumstance. I did not note any other sentry events that weren't from internal testing, but I could have missed them within the grouped Sentry issue.

I traced the exception back to this code in block.native.js, where blockType.getWrapperEditProps was being accessed when blockType did not exist. I then noted the web implementation adds logic to check if blockTypes exists before getting wrapperProps.

The fix proposed in WordPress/gutenberg#56846 prevents the crash and improves alignment with web behavior. I'm wondering if it's the best fix, however, as we haven't encountered this error with other blocks. It may have something to do with the <!-- wp:jetpack/paywall /--> block name, and these changes to unregister this block when the postType is a page: Automattic/jetpack@014b087. I tried investigating from the Jetpack side within the paywall block, but did not note anything that would resolve the crash.

@fluiddot @geriux I requested review on the PR if you have any suggestions.