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

fix: add environment variable to disable LWC version mismatch loglines #5187

Merged
merged 8 commits into from
Feb 28, 2025

Conversation

nrkruk
Copy link
Collaborator

@nrkruk nrkruk commented Feb 3, 2025

Details

When using LWR local dev for experience sites, every SSR request logs an LWC version mismatch error. This is due to the fact that the engine-server is intentionally reloaded on a per page basis and not cached in memory. Therefore the mechanisms in place to only log a the version mismatch once do not work. The logging noise from this makes observing actual useful errors during SSR more difficult.

My change just introduces a new environment variable that can be set on the LWR side to disable this logging during local development.

Would like to backport this also to spring25

Does this pull request introduce a breaking change?

  • 😮‍💨 No, it does not introduce a breaking change.

Does this pull request introduce an observable change?

  • 🤞 No, it does not introduce an observable change.

GUS work item

@W-17740011@

@nrkruk nrkruk requested a review from a team as a code owner February 3, 2025 23:24
Comment on lines 64 to 68
}).not.toLogErrorDev(
new RegExp(
`LWC WARNING: current engine is v${process.env.LWC_VERSION}, but template was compiled with v123.456.789`
)
);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
}).not.toLogErrorDev(
new RegExp(
`LWC WARNING: current engine is v${process.env.LWC_VERSION}, but template was compiled with v123.456.789`
)
);
}).not.toLogErrorDev(/v123\.456\.789/);

Checking that we're not logging such a long message feels easy to get an accidental false positive, if the error text ever changes. We should just check for keywords to be more flexible.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure I can make it more generic

@@ -38,6 +38,11 @@ export function checkVersionMismatch(
) {
const versionMatcher = func.toString().match(LWC_VERSION_COMMENT_REGEX);
if (!isNull(versionMatcher) && !warned) {
if (process?.env?.SKIP_LWC_VERSION_MISMATCH_CHECK === 'true') {
Copy link
Collaborator

Choose a reason for hiding this comment

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

process?.env
Are we expecting to encounter a scenario where the process variable is declared but null/undefined?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

was just being extra cautious - I didn't know how things were compiled (and what is shipped to the browser vs whats available in server side engine). Didn't want to unintentionally break something for this one usecase.

@@ -55,6 +55,9 @@ function sharedPlugins() {
// This is only used inside @lwc/engine-dom and @lwc/engine-server
// Elsewhere, it _not_ be replaced, so that it can be replaced later (e.g. in @lwc/engine-core)
'process.env.IS_BROWSER': packageName === '@lwc/engine-dom' ? 'true' : 'false',
...(packageName === '@lwc/engine-dom'
? { 'process.env.SKIP_LWC_VERSION_MISMATCH_CHECK': 'false' }
: {}),
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@divmain is this right? Or what were you looking for

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 26, 2025

/nucleus test

@wjhsf wjhsf enabled auto-merge (squash) February 26, 2025 21:05
auto-merge was automatically disabled February 27, 2025 23:16

Head branch was pushed to by a user without write access

@nrkruk
Copy link
Collaborator Author

nrkruk commented Feb 27, 2025

/nucleus test

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus test

@nrkruk nrkruk enabled auto-merge (squash) February 28, 2025 20:50
@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus ignore --reason "unrelated __lwc issue in webruntime"

Copy link
Contributor

⚠ The test stage has not been run for this PR. Nothing to ignore.

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus test

@nrkruk nrkruk self-assigned this Feb 28, 2025
@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus ignore --reason "unrelated __lwc issue in webruntime"

Copy link
Contributor

⚠ The test stage has a status of running, which cannot be ignored.

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus ignore --reason "unrelated __lwc issue in webruntime"

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus test

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus ignore --reason "unrelated __lwc issue in webruntime"

Copy link
Contributor

⚠ The test stage has a status of cancelled, which cannot be ignored.

@wjhsf
Copy link
Collaborator

wjhsf commented Feb 28, 2025

/nucleus ignore --reason "unrelated __lwc issue in webruntime"

@nrkruk nrkruk merged commit 2937602 into salesforce:master Feb 28, 2025
14 of 18 checks passed
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.

3 participants