-
Notifications
You must be signed in to change notification settings - Fork 83
fix(holocron): bad modules could cause crashes and prevent restart #631
Conversation
📊 Bundle Size Report
|
version, | ||
}); | ||
// not ideal but need to wait for app to poll; | ||
await waitFor(5000); |
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.
Are we loading the same module 'cultured-frankie';
again? if so we should try and merge this test with the one above if you are able to get both error messages at the same time. This is to avoid overloading the integration tests and make them take longer unnecessarily
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 was only able to get one regex matcher to work at a time within a single test case. Thats why I added another test case
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.
What does the log look like? does it log both lines?
/Failed to get external react-intl from root module/
and
/There was an error loading module (?<moduleName>.*) at (?<url>.*). Reverting back to (?<workingModule>.*)
?
If so we should try and find why the regex is not matching in one single case, loading the same module to the module map twice and that 5sec delay is expensive if we can avoid it 👍
// eslint-disable-next-line no-useless-escape | ||
expect(workingUrl).toBe(`${testCdnUrl}/${gitSha}/${moduleName}/0.0.0/${moduleName}.node.js\"}`); | ||
}); | ||
test('fails to get external `semver` for child module as an unsupplied `requiredExternal` for new module in mooduleMap', async () => { |
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.
have we not tested the same scenario above when requiring react-intl
? the only difference I can see is unhealthy-frank
tries to load a different external semver
?
If this test is to test the scenario when 2 modules with broken required externals are deployed consecutively, then the afterEach in line 754 is resetting the module map anyway and removing cultured-frankie
from the previous test
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.
This test case test when a new module is added to the module map with an error. The previous test case tests when a module's version is updated with an issue
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.
right so we are testing 1 case when the same module is updated (version bump) and it is broken and also when a brand new module which is broken is added for the first time? is that right?
@@ -0,0 +1,31 @@ | |||
{ | |||
"name": "unhealthy-frank", |
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 wonder if we can reuse any of the other franks rather than creating a brand new one? If we deploy the correct version of the root module that doesn't provide any externals, I think cultured-frankie@0.0.1
should be enough?
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 was easier to add a new module that only had one version with an issue, than to manage an existing module with one working version and one broken one
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 am just thinking that it is more work to maintain another frank but I guess now we removed the package-locks from them we shouldn't need to change them too much.
Is it achievable with the franks that we already got? if so maybe double check with the team to see what's their preference
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.
maintenance aside, building another module would also be expensive and increase integration tests build time
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.
An additional version of an existing module would have the same downside.
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.
left comments
version, | ||
}); | ||
// not ideal but need to wait for app to poll; | ||
await waitFor(5000); |
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 was only able to get one regex matcher to work at a time within a single test case. Thats why I added another test case
// eslint-disable-next-line no-useless-escape | ||
expect(workingUrl).toBe(`${testCdnUrl}/${gitSha}/${moduleName}/0.0.0/${moduleName}.node.js\"}`); | ||
}); | ||
test('fails to get external `semver` for child module as an unsupplied `requiredExternal` for new module in mooduleMap', async () => { |
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.
This test case test when a new module is added to the module map with an error. The previous test case tests when a module's version is updated with an issue
@@ -0,0 +1,31 @@ | |||
{ | |||
"name": "unhealthy-frank", |
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 was easier to add a new module that only had one version with an issue, than to manage an existing module with one working version and one broken one
version: modVersion, | ||
}); | ||
// not ideal but need to wait for app to poll; | ||
await waitFor(5000); |
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.
Why don't we set a lower max pall time for the integration tests?
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.
5 seconds is hardcoded as the min - https://github.com/americanexpress/one-app/blob/main/src/server/utils/pollModuleMap.js#L35-L40
await expect(requiredExternalsError).resolves.toMatch(revertErrorMatch); | ||
expect(problemModule).toBe(modName); | ||
expect(problemModuleUrl).toBe(`${testCdnUrl}/${gitSha}/${modName}/${modVersion}/${modName}.node.js`); | ||
// eslint-disable-next-line no-useless-escape |
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.
Is this needed?
@@ -0,0 +1,31 @@ | |||
{ | |||
"name": "unhealthy-frank", |
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.
An additional version of an existing module would have the same downside.
prod-sample/sample-modules/unhealthy-frank/0.0.0/src/components/UnhealthyFrank.jsx
Outdated
Show resolved
Hide resolved
This pull request is stale because it has been open 30 days with no activity. |
…nexpress/one-app into test/holocronIntegration
moduleName: modName, | ||
version: modVersion, | ||
}); | ||
// not ideal but need to wait for app to poll; |
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.
Please set a lower max poll time instead of waiting a full 5s
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.
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.
also for future reference here is where we set it - https://github.com/americanexpress/one-app/blob/main/prod-sample/one-app/base.env#L14
Approved from what you have but we will need to fix those other tests |
Description
Updates holocron to v1.2.0, which includes checks to prevent bad modules from stopping module map polling.
Adds integration tests to an upcoming change to holocron
Motivation and Context
This new version of holocron will prevent one-app from crashing when a bad module is in the module map.
On one-app start, the server will log an error stating the bad module will be ignored until the next poll where the module succeeds to load.
If one-app is already running, it will log an error stating the bad module's name, and revert back to a working module.
How Has This Been Tested?
integration tests cover:
Types of Changes
Checklist:
What is the Impact to Developers Using One App?