-
Notifications
You must be signed in to change notification settings - Fork 189
Add new loading mode: local #6127
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
base: main
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
c3318c7
to
29f77cf
Compare
29f77cf
to
5349676
Compare
Coverage report
Show new covered files 🐣
Show files with reduced coverage 🔻
Test suite run success3028 tests passing in 1311 suites. Report generated by 🧪jest coverage report action from 5349676 |
@@ -466,6 +472,8 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS | |||
|
|||
if (specification) { | |||
usedKnownSpecification = true |
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.
It's not your change, but usedKnownSpecification
seems pointless in this method since if there is no specification we always return early from the method, so there's no need to be checking usedKnownSpecification
further down.
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.
Actually, that's still useful when not using the local
mode. It makes sense for the report
mode.
@@ -466,6 +472,8 @@ class AppLoader<TConfig extends AppConfiguration, TModuleSpec extends ExtensionS | |||
|
|||
if (specification) { | |||
usedKnownSpecification = true | |||
} else if (this.mode === 'local') { | |||
return undefined |
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.
Do we have a good sense of how the contents of the loaded app (the extensions list) are used throughout the CLI? If we knew this was only used by build
it would be safer, but this loader could be used anywhere - how can we guarantee that all usages (current and future) will be OK with skipping an unknown extension?
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 is tricky, for instance the only command that uses the report
loader mode is the app info
command, because we want to surface errors but still load the app.
But we can't prevent other commands from using that loading mode (unless we add a special eslint rule I guess). That's why we called it unsafeReportMode
.
In this case, the local
mode will only be used when using the localAppContext
, which should only be used by unauthenticated commands (app build
and app function
).
@@ -162,6 +161,6 @@ export async function localAppContext({ | |||
directory, | |||
userProvidedConfigName, | |||
specifications, | |||
mode: unsafeReportMode ? 'report' : 'strict', | |||
mode: 'local', |
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.
I think since we dont' know who is using localAppContext
, it's dangerous to assume we always want local
here. I think we should pass an argument into localAppContext
(similar to how it was before) so that the command can determine whether it's safe to skip unknown extensions when loading the local app. Since there might be cases where a default value of local
is wrong and then bad things happen
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.
Umm, my assumption was that if this is a local app, the expectation is that only local specifications can be used, and we should never crash in that case.
Since there might be cases where a default value of local is wrong and then bad things happen
I can't imagine a case where you would want to load the app with the local specs, but crash if there is an unknown extension 🤔. Right now the default mode is strict
and that's what's causing the issues that made us make this change
The way I see it:
localAppContext
-> local
mode
linkedAppContext
-> strict
or report
modes
WHY are these changes introduced?
To improve the handling of unknown extension types in local development mode, allowing the app to load successfully even when unknown extension types are present.
WHAT is this pull request doing?
local
mode to theAppLoaderMode
type, which ignores errors for unknown extension typeslocalAppContext
function to use the newlocal
mode instead ofstrict
How to test your changes?
For know extensions only accessible when authenticated:
admin_link
extensionsapp build
andapp deploy
should work.build
will ignore the admin_link extensionFor completely unknown extensions:
admin_link
extension.app build
still works because it ignore unknown extensions,app deploy
should crash.Measuring impact
How do we know this change was effective? Please choose one:
Checklist