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

fix(server): devCDN should not crash when bundles are not present #1343

Closed
wants to merge 4 commits into from

Conversation

PixnBits
Copy link
Contributor

@PixnBits PixnBits commented Mar 26, 2024

Description

The development CDN crashes when performing the substitution in the URL of a nonexistant bundle.

Motivation and Context

The legacy browser bundle is optional, not required.

err: {
    "type": "TypeError",
    "message": "Cannot read properties of undefined (reading 'url')",
    "stack":
        TypeError: Cannot read properties of undefined (reading 'url')
            at .../one-app/lib/server/utils/devCdnFactory.js:44:53

How Has This Been Tested?

Unit tests added that have only one bundle each.

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?

Resolve the server crashing on them when running with modules that have not opted in to building the legacy browser bundles.

e.g. the legacy browser bundle is optional, not required
@PixnBits PixnBits requested review from a team as code owners March 26, 2024 17:11
Copy link
Contributor

github-actions bot commented Mar 26, 2024

Size Change: 0 B

Total Size: 735 kB

ℹ️ View Unchanged
Filename Size
./build/app/app.js 187 kB
./build/app/app~vendors.js 411 kB
./build/app/runtime.js 7.07 kB
./build/app/service-worker-client.js 7.25 kB
./build/app/vendors.js 123 kB

compressed-size-action

JAdshead
JAdshead previously approved these changes Mar 26, 2024
Copy link
Member

@code-forger code-forger left a comment

Choose a reason for hiding this comment

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

This Pr fixes a symptom, not a cause, the root cause is fixed elsewhere

Comment on lines +81 to +89
Object
.values(module)
.filter((bundle) => Object.hasOwnProperty.call(bundle, 'url'))
.forEach((bundle) => {
/* eslint-disable-next-line no-param-reassign -- the in-memory copy is created here during
// the read from network, so the replacement side-effect of this loop is local to the
// consumeRemoteRequest function and not to any arguments */
bundle.url = bundle.url.replace(new URL(bundle.url).origin, oneAppDevStaticsAddress);
});
Copy link
Contributor Author

@PixnBits PixnBits Mar 26, 2024

Choose a reason for hiding this comment

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

I'm not sure where the test(s) for the previous implementation is/are, so this needs attention
superseding context though: #1343 (review)

@PixnBits
Copy link
Contributor Author

This Pr fixes a symptom, not a cause, the root cause is fixed elsewhere

americanexpress/one-app-cli#629

@PixnBits PixnBits closed this Mar 26, 2024
@PixnBits PixnBits deleted the fix/devCDN-legacy-browser-bundle-not-required branch April 2, 2024 16:26
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants