-
Notifications
You must be signed in to change notification settings - Fork 3
task: Log plugin load and editor initialization failures #249
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
Changes from all commits
3de9067
6c8cb5d
0b669e0
3dd8b9a
01cbba6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,13 +1,18 @@ | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { awaitGBKitGlobal, editorLoaded, getGBKit } from './bridge'; | ||
| import { | ||
| awaitGBKitGlobal, | ||
| editorLoaded, | ||
| getGBKit, | ||
| logException, | ||
| } from './bridge'; | ||
| import { configureLocale } from './localization'; | ||
| import { loadEditorAssets } from './editor-loader'; | ||
| import { initializeVideoPressAjaxBridge } from './videopress-bridge'; | ||
| import { initializeFetchInterceptor } from './fetch-interceptor'; | ||
| import EditorLoadError from '../components/editor-load-error'; | ||
| import { error } from './logger'; | ||
| import { setLogLevel, error } from './logger'; | ||
| import { setUpGlobalErrorHandlers } from './global-error-handler'; | ||
| import { Platform } from './platform'; | ||
| import './editor-styles'; | ||
|
|
@@ -23,6 +28,7 @@ export async function setUpEditorEnvironment() { | |
| setUpGlobalErrorHandlers(); | ||
| setBodyClasses(); | ||
| await awaitGBKitGlobal(); | ||
| setLogLevelFromGBKit(); | ||
| initializeFetchInterceptor(); | ||
| await configureLocale(); | ||
| await initializeWordPressGlobals(); | ||
|
|
@@ -56,6 +62,18 @@ function setBodyClasses() { | |
| window.document.body.classList.add( ...classNames ); | ||
| } | ||
|
|
||
| /** | ||
| * Set the log level based on GBKit configuration. | ||
| * | ||
| * @return {void} | ||
| */ | ||
| function setLogLevelFromGBKit() { | ||
| const { logLevel } = getGBKit(); | ||
| if ( logLevel ) { | ||
| setLogLevel( logLevel ); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Initialize WordPress global modules. Lazy-loaded to ensure the locale is | ||
| * configured before importing these modules and referencing the corresponding | ||
|
|
@@ -100,7 +118,11 @@ async function loadPluginsIfEnabled() { | |
| try { | ||
| const { allowedBlockTypes } = await loadEditorAssets(); | ||
| return { allowedBlockTypes, pluginLoadFailed: false }; | ||
| } catch { | ||
| } catch ( err ) { | ||
| logException( err, { | ||
| isHandled: true, | ||
| handledBy: 'loadPluginsIfEnabled', | ||
| } ); | ||
|
Comment on lines
+122
to
+125
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve observability of plugin loading failures. |
||
| return { pluginLoadFailed: true }; | ||
| } | ||
| } | ||
|
|
@@ -129,6 +151,10 @@ async function initializeEditor( pluginLoadResult = {} ) { | |
| * @param {Error} err - The error that occurred | ||
| */ | ||
| function handleError( err ) { | ||
| logException( err, { | ||
| isHandled: true, | ||
| handledBy: 'setUpEditorEnvironment', | ||
| } ); | ||
|
Comment on lines
+154
to
+157
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Improve observability of editor initialization failures. |
||
| error( 'Error initializing editor', err ); | ||
| const errorDetails = EditorLoadError( { error: err } ); | ||
| document.body.innerHTML = errorDetails; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -76,10 +76,7 @@ const parseException = ( originalException ) => { | |
| message: extractMessage( originalException ), | ||
| }; | ||
|
|
||
| const stacktrace = parseStacktrace( originalException ); | ||
| if ( stacktrace.length ) { | ||
| exception.stacktrace = stacktrace; | ||
| } | ||
| exception.stacktrace = parseStacktrace( originalException ); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always set the E.g., if |
||
|
|
||
| if ( exception.type === undefined && exception.message === '' ) { | ||
| exception.message = 'Unknown error'; | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hoisted from
src/utils/editor.jsxto ensure messages from editor initialization log.