-
Notifications
You must be signed in to change notification settings - Fork 19
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
Handle plugin errors #453
Merged
+174
−170
Merged
Handle plugin errors #453
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
da10f2a
chore: move `PluginError` to plugins package and extend functionality
DavieReid c75d0f5
feat: update error handling for plugin and serialiser runners
DavieReid 5e7a1c6
refactor: update error handling in `$RefPlugin`
DavieReid beffac0
fix: remove `saveContent` API from plugins
DavieReid 1dcf068
feat: expose plugin errors using list sources admin API
DavieReid 867becc
chore: add changeset
DavieReid File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,14 +5,22 @@ import fs from 'fs'; | |
import { DirectoryJSON, Volume } from 'memfs'; | ||
import { switchMap, tap } from 'rxjs'; | ||
|
||
import type { Page, WorkerData } from '@jpmorganchase/mosaic-types'; | ||
import type { Page, PluginErrors, WorkerData } from '@jpmorganchase/mosaic-types'; | ||
|
||
import FileAccess from '../filesystems/FileAccess.js'; | ||
import MutableVolume from '../filesystems/MutableVolume.js'; | ||
import createConfig from '../helpers/createConfig.js'; | ||
import { bindPluginMethods, bindSerialiser } from '../plugin/index.js'; | ||
import createSourceObservable from './helpers/createSourceObservable.js'; | ||
|
||
const trackPluginErrors = (errors: PluginErrors, lifecycleMethod: string) => { | ||
const errorsBuffer = Buffer.from(JSON.stringify({ errors, lifecycleMethod })); | ||
parentPort.postMessage({ | ||
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. Plugin methods that start with a |
||
type: 'track', | ||
data: errorsBuffer | ||
}); | ||
}; | ||
|
||
const workerData: WorkerData<{ cache: boolean }> = unTypedWorkerData; | ||
|
||
if (isMainThread) { | ||
|
@@ -22,7 +30,7 @@ if (isMainThread) { | |
let config; | ||
let filesystem; | ||
const serialiser = await bindSerialiser(workerData.serialisers); | ||
const pluginApi = await bindPluginMethods(workerData.plugins); | ||
const pluginApi = await bindPluginMethods(workerData.plugins, trackPluginErrors); | ||
const cachePath = path.join(process.cwd(), '.tmp', '.cache', `${workerData.name}.json`); | ||
|
||
if (workerData.options.cache !== false) { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Will update the type of this when we have identified what we want to do with the errors. They are logged to the console but it would be nice to provide an API that can be used to see the errors
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.
might be worth leaving this till after we merged in Next 13 changes... as right now, it's easy to rebase that branch, when we confine other changes to core and not change any of the UI
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.
That's fine...just pushed a change that will allow you to see the plugin errors when using the list sources admin API. Should be good enough for us to diagnose problems.