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

Send button for GRPC in dev mode broken #30288

Closed
knoma opened this issue Jan 10, 2023 · 9 comments · Fixed by #30407
Closed

Send button for GRPC in dev mode broken #30288

knoma opened this issue Jan 10, 2023 · 9 comments · Fixed by #30407
Assignees
Labels
Milestone

Comments

@knoma
Copy link

knoma commented Jan 10, 2023

Describe the bug

Currently I'm unable to send a request via the dev UI for for GRPC, the call doesn't get triggered.

In the javascript console I can see this error at startup

Uncaught SyntaxError: Unexpected token '-' (at service?name=hello.HelloGrpc:571:40)

                            var quarkus-generated-sourcesPackages = [];

When I click send I get this error

Uncaught ReferenceError: sendTestRequest is not defined
                          onclick="sendTestRequest('hello.HelloGrpc','SayHello', 'UNARY')">

I get the errors on Chrome and Safari, I tried restart and a empty browser cache.

I just created a new grpc project using quarkus 2.15.2 and running the example

Expected behavior

No response

Actual behavior

No response

How to Reproduce?

No response

Output of uname -a or ver

22.2.0 Darwin Kernel Version 22.2.0: Fri Nov 11 02:08:47 PST 2022; root:xnu-8792.61.2~4/RELEASE_X86_64 x86_64

Output of java -version

openjdk 17.0.5 2022-10-18 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.15.2

Build tool (ie. output of mvnw --version or gradlew --version)

No response

Additional information

image

@knoma knoma added the kind/bug Something isn't working label Jan 10, 2023
@quarkus-bot
Copy link

quarkus-bot bot commented Jan 10, 2023

/cc @alesj(grpc), @cescoffier(grpc) @mkouba

@cescoffier
Copy link
Member

I just tried with the gRPC quickstart and Quarkus 2.15.3.Final, and it works.

Can you attach a reproducer?

@knoma
Copy link
Author

knoma commented Jan 13, 2023

thank you for checking, no luck. Still same error even after creating a new app.

I tried this on macOS 13.1 with Quarkus 2.15.3 and java 17 using these param to create the grpc starter

image

I just run ./gradlew quarkusDev after the download but the error was still in Safari and Chrome (private and incognito mode)

image

image

@knoma
Copy link
Author

knoma commented Jan 13, 2023

looks the generated variable name quarkus-generated-sourcesPackages isn't a valid js format.

image

@cescoffier
Copy link
Member

Ah, there is one big difference: you used Gradle. Can you try with maven, so we can pinpoint the problem?

@knoma
Copy link
Author

knoma commented Jan 14, 2023

With maven I have no errors in the js console and I can submit the req successfully.

I also saw this message when I open unary query site Web Socket bridge to gRPC connected, before I just have yellow spot (I thought it's a html glitch), plus in the console it says websocket connected.

image

In the gradle version the js var is called


                            var sourceMap = {};
                            var quarkus-generated-sourcesPackages = [];
                            quarkus-generated-sourcesPackages.push("grpc.org.acme")

In the maven version this shows up


                           var sourceMap = {};
                            var javaPackages = [];
                            javaPackages.push("org.acme")

I also the function sendTestRequest that was missing Bradley is defined now in maven


        function sendTestRequest(serviceName, methodName, methodType) {
            const queryIdentifier = `${serviceName}#${methodName}`;
            var connection = Array.from(connections.values()).find(conn => conn.queryIdentifier == queryIdentifier);
            const testRequest = document.getElementById(serviceName + "/" + methodName + "_request");
            if (!connection || methodType == 'UNARY') {
                requestId ++;
                connection = {
                    id: requestId,
                    queryIdentifier: queryIdentifier,
                    responseElement: document.getElementById(serviceName + "/" + methodName + "_response"),
                    responseText: '',
                    unary: methodType == 'UNARY'
                };
                connections.set(requestId, connection);
            }

            const request = {
                serviceName: serviceName,
                methodName: methodName,
                id: requestId,
                content: testRequest.value
            };

            grpcWS.send(JSON.stringify(request));

            if (methodType != 'UNARY') {
              showConnected(connection);
            }

@cescoffier cescoffier self-assigned this Jan 16, 2023
@cescoffier
Copy link
Member

So, the bug is actually not related to gRPC but to the dev UI.
It injects the source map, but the code does not handle Gradle correctly. It would happen in many other places as soon as you use Gradle with generated sources.

There is a template in each Dev UI pages which does:

{#for sourcePackageEntry in ideInfo:sourcePackages}
    var {sourcePackageEntry.key}Packages = [];
{#for rootPackage in sourcePackageEntry.value}
    {sourcePackageEntry.key}Packages.push("{rootPackage}")
{/for}

But with Gradle it generates:

var quarkus-generated-sourcesPackages = [];
quarkus-generated-sourcesPackages.push("grpc.org.acme")
sourceMap["quarkus-generated-sources"] = quarkus-generated-sourcesPackages;

As you can expect, quarkus-generated-sourcesPackages is not a valid identifier.

\CC @geoand

@geoand
Copy link
Contributor

geoand commented Jan 17, 2023

Interesting, I'll have a look next week (I will be out this week)

@cescoffier
Copy link
Member

I'm having a look - but do be clear, I'm not sure I understand what I'm doing :-D

cescoffier added a commit that referenced this issue Jan 17, 2023
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix #30288
@cescoffier cescoffier added area/gradle Gradle and removed area/grpc gRPC labels Jan 17, 2023
@quarkus-bot quarkus-bot bot added this to the 2.17 - main milestone Jan 17, 2023
michelle-purcell pushed a commit to michelle-purcell/quarkus that referenced this issue Jan 17, 2023
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix quarkusio#30288
michelle-purcell pushed a commit to michelle-purcell/quarkus that referenced this issue Jan 17, 2023
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix quarkusio#30288
@gsmet gsmet modified the milestones: 2.17 - main, 2.16.0.Final Jan 17, 2023
gsmet pushed a commit to gsmet/quarkus that referenced this issue Jan 17, 2023
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix quarkusio#30288

(cherry picked from commit 5079fd0)
mfpc pushed a commit to mfpc/quarkus that referenced this issue Jan 19, 2023
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix quarkusio#30288
ebullient pushed a commit to maxandersen/quarkus that referenced this issue Jan 24, 2023
…..), the JavaScript identifiers used to build the source map were not valid (because they contained `-`).

This commit fixes it by replacing the `-` with `_`.

Fix quarkusio#30288
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants