Skip to content
This repository has been archived by the owner on May 3, 2024. It is now read-only.

fix(holocron): bad modules could cause crashes and prevent restart #631

Merged
merged 11 commits into from
Jan 28, 2022

Conversation

Matthew-Mallimo
Copy link
Member

@Matthew-Mallimo Matthew-Mallimo commented Dec 8, 2021

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:

  • one-app start up with a bad module
    • Should start up normally, just ignoring the bad module
  • one-app running with moduleA at 0.0.0, and moduleA 0.0.1 is deployed with problems
    • one-app should continue to poll ignoring v0.0.1 until its healthy
  • one-app running when a new module is deployed with issues
    • should continue to poll and ignore the broken module until its healthy

Types of Changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation (adding or updating documentation)
  • Dependency update
  • Security update

Checklist:

  • My change requires a change to the documentation and I have updated the documentation accordingly.
  • These changes should be applied to a maintenance branch.
  • This change requires cross browser checks.
  • Performance tests should be ran against the server prior to merging.
  • This change impacts caching for client browsers.
  • This change impacts HTTP headers.
  • This change adds additional environment variable requirements for One App users.
  • I have added the Apache 2.0 license header to any new files created.

What is the Impact to Developers Using One App?

@github-actions github-actions bot added the test label Dec 8, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Dec 9, 2021

📊 Bundle Size Report

file name size on disk gzip
app.js 314.2KB 93.2KB
runtime.js 15.6KB 5.5KB
vendors.js 129.1KB 40KB
app~vendors.js 427.4KB 110.4KB
service-worker-client.js 17.1KB 5.3KB
legacy/app.js 334.8KB 98KB
legacy/runtime.js 15.6KB 5.5KB
legacy/vendors.js 189.4KB 51.7KB
legacy/app~vendors.js 449.1KB 116.4KB
legacy/service-worker-client.js 17.6KB 5.5KB

Generated by 🚫 dangerJS against 98e2774

@Matthew-Mallimo Matthew-Mallimo requested a review from a team December 10, 2021 14:44
__tests__/integration/one-app.spec.js Show resolved Hide resolved
__tests__/integration/one-app.spec.js Show resolved Hide resolved
version,
});
// not ideal but need to wait for app to poll;
await waitFor(5000);
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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 👍

prod-sample/sample-modules/unhealthy-frank/0.0.0/README.md Outdated Show resolved Hide resolved
// 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 () => {
Copy link
Contributor

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

Copy link
Member Author

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

Copy link
Contributor

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",
Copy link
Contributor

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?

Copy link
Member Author

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

Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Member

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.

Copy link
Member Author

@Matthew-Mallimo Matthew-Mallimo left a 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);
Copy link
Member Author

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 () => {
Copy link
Member Author

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",
Copy link
Member Author

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

@Matthew-Mallimo Matthew-Mallimo requested a review from a team December 14, 2021 14:38
version: modVersion,
});
// not ideal but need to wait for app to poll;
await waitFor(5000);
Copy link
Member

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?

Copy link
Contributor

Choose a reason for hiding this comment

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

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
Copy link
Member

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",
Copy link
Member

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/README.md Outdated Show resolved Hide resolved
prod-sample/sample-modules/unhealthy-frank/0.0.0/README.md Outdated Show resolved Hide resolved
@github-actions
Copy link
Contributor

This pull request is stale because it has been open 30 days with no activity.

@Matthew-Mallimo Matthew-Mallimo marked this pull request as ready for review January 27, 2022 16:23
@Matthew-Mallimo Matthew-Mallimo requested a review from a team as a code owner January 27, 2022 16:23
@Matthew-Mallimo Matthew-Mallimo changed the title test(integration): added integration test for new holocron error feat(holocron): upgrade holocron to 1.2.0 Jan 27, 2022
@10xLaCroixDrinker 10xLaCroixDrinker changed the title feat(holocron): upgrade holocron to 1.2.0 fix(holocron): bad modules could cause crashes and prevent restart Jan 27, 2022
moduleName: modName,
version: modVersion,
});
// not ideal but need to wait for app to poll;
Copy link
Member

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

JAdshead
JAdshead previously approved these changes Jan 27, 2022
@JAdshead
Copy link
Contributor

Approved from what you have but we will need to fix those other tests

@10xLaCroixDrinker 10xLaCroixDrinker requested a review from a team January 27, 2022 19:30
@github-actions github-actions bot removed the stale-pr label Jan 28, 2022
@10xLaCroixDrinker 10xLaCroixDrinker merged commit 3e53147 into main Jan 28, 2022
@10xLaCroixDrinker 10xLaCroixDrinker deleted the test/holocronIntegration branch January 28, 2022 18:43
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants