-
Notifications
You must be signed in to change notification settings - Fork 867
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 vaadin latest dep test #3785
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...in/java/io/opentelemetry/javaagent/instrumentation/vaadin/NodeUpdaterInstrumentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Copyright The OpenTelemetry Authors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package io.opentelemetry.javaagent.instrumentation.vaadin; | ||
|
||
import static net.bytebuddy.matcher.ElementMatchers.named; | ||
|
||
import io.opentelemetry.javaagent.extension.instrumentation.TypeInstrumentation; | ||
import io.opentelemetry.javaagent.extension.instrumentation.TypeTransformer; | ||
import java.util.Map; | ||
import net.bytebuddy.asm.Advice; | ||
import net.bytebuddy.description.type.TypeDescription; | ||
import net.bytebuddy.matcher.ElementMatcher; | ||
|
||
/** | ||
* This advice is used only when running tests. Works around an issue running testLatestDeps. | ||
* Currently the latest vaadin release is 20, it is likely that this advice can be deleted when | ||
* there is a new version. | ||
*/ | ||
public class NodeUpdaterInstrumentation implements TypeInstrumentation { | ||
|
||
@Override | ||
public ElementMatcher<TypeDescription> typeMatcher() { | ||
return named("com.vaadin.flow.server.frontend.NodeUpdater"); | ||
} | ||
|
||
@Override | ||
public void transform(TypeTransformer transformer) { | ||
transformer.applyAdviceToMethod( | ||
named("getDefaultDevDependencies"), | ||
NodeUpdaterInstrumentation.class.getName() + "$FixDependenciesAdvice"); | ||
} | ||
|
||
@SuppressWarnings("unused") | ||
public static class FixDependenciesAdvice { | ||
|
||
@Advice.OnMethodExit(onThrowable = Throwable.class, suppress = Throwable.class) | ||
public static void onExit(@Advice.Return Map<String, String> dependencies) { | ||
// If there is a dependency to workbox-webpack-plugin:6.1.0 add a dependency to | ||
// workbox-build:6.1.0. This is needed because workbox-build:6.2.0 that gets chosen without | ||
// having an explicit dependency to workbox-build here is incompatible with 6.1.0. | ||
if ("6.1.0".equals(dependencies.get("workbox-webpack-plugin"))) { | ||
dependencies.put("workbox-build", "6.1.0"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
can you add to this comment explaining this problem only affects our tests, and is not a problem for end users?
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 would assume that it is a problem for at least some users GoogleChrome/workbox#2904 Our test isn't exactly a regular vaadin application. We let vaadin development mode generate a bunch of files each time test is first run after clean that regular users would add to version control. I suspect that the javascript tooling used probably doesn't attempt to find new package versions on each run so if they set up their project before yesterday this is yet to break for them (this is speculation). If it breaks they probably know how to pin package to working version. I also initially tried to make it use the previous working version of
workbox-build
but failed at it. I guess should have usepnpm-lock.yaml
to pin version. So after failing with javascript tooling I turned to what I know, patching java code. As an alternative we could find the latest working vaadin version (something that usesworkbox-webpack-plugin
before 6.x?) and make latest dep tests use that until vaadin switches toworkbox-webpack-plugin
6.2.Edited: there is also a vaadin issue for this vaadin/flow#11524
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 this would be my preference