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

Handle plugin errors #453

Merged
merged 6 commits into from
Aug 23, 2023
Merged

Handle plugin errors #453

merged 6 commits into from
Aug 23, 2023

Conversation

DavieReid
Copy link
Contributor

The primary change included here is that any exceptions raised by plugins during any part of the plugin lifecycle are converted to instances of PluginError and tracked by the source that is running the plugins.

This means plugin errors do not cause the source to close.

Plugin authors should be encouraged to throw aPluginError. Should an error occur when processing a particular page, then the full path to the page can be included in the error descriptor.

I have also removed the saveContent plugin API. This was replaced with workflows some time ago and should have been removed then.

Todo

Now that a source has a collection of plugin errors....how are these surfaced?

@DavieReid DavieReid requested a review from a team as a code owner August 22, 2023 15:54
@changeset-bot
Copy link

changeset-bot bot commented Aug 22, 2023

🦋 Changeset detected

Latest commit: 867becc

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
@jpmorganchase/mosaic-cli Patch
@jpmorganchase/mosaic-core Patch
@jpmorganchase/mosaic-plugins Patch
@jpmorganchase/mosaic-types Patch
@jpmorganchase/mosaic-labs-components Patch
@jpmorganchase/mosaic-components Patch
@jpmorganchase/mosaic-content-editor-plugin Patch
@jpmorganchase/mosaic-create-site Patch
@jpmorganchase/mosaic-from-http-request Patch
@jpmorganchase/mosaic-layouts Patch
@jpmorganchase/mosaic-open-api-component Patch
@jpmorganchase/mosaic-schemas Patch
@jpmorganchase/mosaic-serialisers Patch
@jpmorganchase/mosaic-site-components Patch
@jpmorganchase/mosaic-site-middleware Patch
@jpmorganchase/mosaic-site-preset-styles Patch
@jpmorganchase/mosaic-site Patch
@jpmorganchase/mosaic-source-git-repo Patch
@jpmorganchase/mosaic-source-http Patch
@jpmorganchase/mosaic-source-local-folder Patch
@jpmorganchase/mosaic-standard-generator Patch
@jpmorganchase/mosaic-store Patch
@jpmorganchase/mosaic-theme Patch
@jpmorganchase/mosaic-workflows Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@vercel
Copy link

vercel bot commented Aug 22, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
mosaic ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 23, 2023 0:10am


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({
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plugin methods that start with a $ run inside a child process and must communicate with the parent thread by posting a message.

@@ -36,6 +37,7 @@ export default class Source {
#ignorePages: string[];
#workflows: SourceWorkflow[] = [];
#schedule: SourceSchedule;
#pluginErrors: any = {};
Copy link
Contributor Author

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

@coveralls
Copy link

Pull Request Test Coverage Report for Build 5951061657

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage remained the same at 63.124%

Totals Coverage Status
Change from base Build 5891214239: 0.0%
Covered Lines: 1307
Relevant Lines: 1803

💛 - Coveralls

@DavieReid DavieReid merged commit 0ced179 into main Aug 23, 2023
8 checks passed
@DavieReid DavieReid deleted the handle-plugin-errors branch August 23, 2023 12:37
This was referenced Aug 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants