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

Implement SignalR as middleware for project export enhancement #817

Merged
merged 47 commits into from
Nov 24, 2020

Conversation

imnasnainaec
Copy link
Collaborator

@imnasnainaec imnasnainaec commented Nov 17, 2020

Follow-up to #819

TODO:

  • Unhardcode URL path for signal (@johnthagen)
  • Ensure Docker build works (@johnthagen)
    • Need to proxy to /hub or, perhaps better, move /hub to where all other backend paths are

This change is Reviewable

@codecov-io
Copy link

codecov-io commented Nov 17, 2020

Codecov Report

Merging #817 (4278b21) into master (16f08d4) will decrease coverage by 0.14%.
The diff coverage is 37.30%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #817      +/-   ##
==========================================
- Coverage   51.39%   51.24%   -0.15%     
==========================================
  Files         239      241       +2     
  Lines        6546     6621      +75     
  Branches      420      424       +4     
==========================================
+ Hits         3364     3393      +29     
- Misses       2871     2914      +43     
- Partials      311      314       +3     
Flag Coverage Δ
backend 55.84% <58.18%> (-0.08%) ⬇️
frontend 46.76% <21.12%> (-0.23%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
Backend/Startup.cs 0.00% <0.00%> (ø)
src/components/App/AppLoggedIn.tsx 0.00% <ø> (ø)
src/components/App/DefaultState.tsx 100.00% <ø> (ø)
src/components/App/SignalRHub.tsx 0.00% <0.00%> (ø)
src/components/AppBar/AppBarComponent.tsx 100.00% <ø> (ø)
.../components/ProjectExport/ExportProjectActions.tsx 0.00% <0.00%> (ø)
.../components/ProjectExport/ExportProjectReducer.tsx 44.44% <0.00%> (ø)
src/components/ProjectExport/index.tsx 66.66% <ø> (ø)
...nents/ProjectSettings/ProjectSettingsComponent.tsx 0.00% <ø> (ø)
...teSettings/ProjectManagement/ProjectManagement.tsx 100.00% <ø> (ø)
... and 11 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 16f08d4...4278b21. Read the comment docs.

@lgtm-com

This comment has been minimized.

@sillsdev sillsdev deleted a comment from lgtm-com bot Nov 20, 2020
@sillsdev sillsdev deleted a comment from lgtm-com bot Nov 20, 2020
@lgtm-com

This comment has been minimized.

@lgtm-com

This comment has been minimized.

@johnthagen
Copy link
Collaborator


Backend/Startup.cs, line 94 at r4 (raw file):

                        .AllowAnyHeader()
                        .AllowAnyMethod()
                        .WithOrigins("http://localhost:3000")

Will this affect production? (e.g. non-localhost deployment)

@johnthagen
Copy link
Collaborator


Backend/Startup.cs, line 94 at r4 (raw file):

Previously, jmgrady (Jim Grady) wrote…

This is what is in ./src/types/runtimeConfig.tsx:

  public baseUrl(): string {
    // TODO: Remove support for previous configuration solution when
    //  Docker-based installation is used in production.
    if (window.runtimeConfig.hasOwnProperty("baseUrl")) {
      return window.runtimeConfig.baseUrl;
    }

    let baseUrl = "";
    if (window.runtimeConfig.hasOwnProperty("useConnectionBaseUrlForApi")) {
      baseUrl = `${window.location.protocol}//${window.location.host}`;
    } else {
      baseUrl = defaultConfig.baseUrl;
    }
    return baseUrl;
  }

Does this meet your needs?

Done

@johnthagen
Copy link
Collaborator


src/components/App/SignalRHub.tsx, line 49 at r17 (raw file):

        }
      };
      connection

@imnasnainaec The export works when I test it, but I do see the following error logged to the console:

index.js:1 Error: Cannot start a HubConnection that is not in the 'Disconnected' state.
    at HubConnection.<anonymous> (HubConnection.ts:163)
    at step (HubConnection.ts:2)
    at Object.next (HubConnection.ts:2)
    at HubConnection.ts:2
    at new Promise (<anonymous>)
    at push../node_modules/@microsoft/signalr/dist/esm/HubConnection.js.__awaiter (HubConnection.ts:2)
    at HubConnection.startWithStateTransitions (HubConnection.ts:161)
    at HubConnection.start (HubConnection.ts:157)
    at SignalRHub.tsx:49
    at commitHookEffectListMount (react-dom.development.js:19731)
    at commitPassiveHookEffects (react-dom.development.js:19769)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at flushPassiveEffectsImpl (react-dom.development.js:22853)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at performSyncWorkOnRoot (react-dom.development.js:21737)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at batchedUpdates$1 (react-dom.development.js:21862)
    at Object.notify (Subscription.js:19)
    at Subscription.notifyNestedSubs (Subscription.js:92)
    at Subscription.handleChangeWrapper (Subscription.js:97)
    at Object.dispatch (redux.js:222)
    at e (<anonymous>:1:40553)
    at Object.dispatch (index.js:11)
    at dispatch (<anonymous>:1:28545)
    at ExportProjectActions.tsx:31
    at HubConnection.method (SignalRHub.tsx:45)
    at HubConnection.ts:634
    at Array.forEach (<anonymous>)
    at HubConnection.invokeClientMethod (HubConnection.ts:634)
    at HubConnection.processIncomingData (HubConnection.ts:530)
    at WebSocketTransport.HubConnection.connection.onreceive (HubConnection.ts:102)
    at WebSocket.webSocket.onmessage (WebSocketTransport.ts:94)
console.<computed> @ index.js:1
overrideMethod @ react_devtools_backend.js:2430
(anonymous) @ SignalRHub.tsx:49
Promise.catch (async)
(anonymous) @ SignalRHub.tsx:49
commitHookEffectListMount @ react-dom.development.js:19731
commitPassiveHookEffects @ react-dom.development.js:19769
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
flushPassiveEffectsImpl @ react-dom.development.js:22853
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
performSyncWorkOnRoot @ react-dom.development.js:21737
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
batchedUpdates$1 @ react-dom.development.js:21862
notify @ Subscription.js:19
notifyNestedSubs @ Subscription.js:92
handleChangeWrapper @ Subscription.js:97
dispatch @ redux.js:222
e @ VM347:1
(anonymous) @ index.js:11
dispatch @ VM347:1
(anonymous) @ ExportProjectActions.tsx:31
method @ SignalRHub.tsx:45
(anonymous) @ HubConnection.ts:634
HubConnection.invokeClientMethod @ HubConnection.ts:634
HubConnection.processIncomingData @ HubConnection.ts:530
HubConnection.connection.onreceive @ HubConnection.ts:102
webSocket.onmessage @ WebSocketTransport.ts:94

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 of 29 files reviewed, 1 unresolved discussion (waiting on @jasonleenaylor and @johnthagen)


src/components/App/SignalRHub.tsx, line 49 at r17 (raw file):

Previously, johnthagen wrote…

@imnasnainaec The export works when I test it, but I do see the following error logged to the console:

index.js:1 Error: Cannot start a HubConnection that is not in the 'Disconnected' state.
    at HubConnection.<anonymous> (HubConnection.ts:163)
    at step (HubConnection.ts:2)
    at Object.next (HubConnection.ts:2)
    at HubConnection.ts:2
    at new Promise (<anonymous>)
    at push../node_modules/@microsoft/signalr/dist/esm/HubConnection.js.__awaiter (HubConnection.ts:2)
    at HubConnection.startWithStateTransitions (HubConnection.ts:161)
    at HubConnection.start (HubConnection.ts:157)
    at SignalRHub.tsx:49
    at commitHookEffectListMount (react-dom.development.js:19731)
    at commitPassiveHookEffects (react-dom.development.js:19769)
    at HTMLUnknownElement.callCallback (react-dom.development.js:188)
    at Object.invokeGuardedCallbackDev (react-dom.development.js:237)
    at invokeGuardedCallback (react-dom.development.js:292)
    at flushPassiveEffectsImpl (react-dom.development.js:22853)
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushPassiveEffects (react-dom.development.js:22820)
    at performSyncWorkOnRoot (react-dom.development.js:21737)
    at react-dom.development.js:11089
    at unstable_runWithPriority (scheduler.development.js:653)
    at runWithPriority$1 (react-dom.development.js:11039)
    at flushSyncCallbackQueueImpl (react-dom.development.js:11084)
    at flushSyncCallbackQueue (react-dom.development.js:11072)
    at batchedUpdates$1 (react-dom.development.js:21862)
    at Object.notify (Subscription.js:19)
    at Subscription.notifyNestedSubs (Subscription.js:92)
    at Subscription.handleChangeWrapper (Subscription.js:97)
    at Object.dispatch (redux.js:222)
    at e (<anonymous>:1:40553)
    at Object.dispatch (index.js:11)
    at dispatch (<anonymous>:1:28545)
    at ExportProjectActions.tsx:31
    at HubConnection.method (SignalRHub.tsx:45)
    at HubConnection.ts:634
    at Array.forEach (<anonymous>)
    at HubConnection.invokeClientMethod (HubConnection.ts:634)
    at HubConnection.processIncomingData (HubConnection.ts:530)
    at WebSocketTransport.HubConnection.connection.onreceive (HubConnection.ts:102)
    at WebSocket.webSocket.onmessage (WebSocketTransport.ts:94)
console.<computed> @ index.js:1
overrideMethod @ react_devtools_backend.js:2430
(anonymous) @ SignalRHub.tsx:49
Promise.catch (async)
(anonymous) @ SignalRHub.tsx:49
commitHookEffectListMount @ react-dom.development.js:19731
commitPassiveHookEffects @ react-dom.development.js:19769
callCallback @ react-dom.development.js:188
invokeGuardedCallbackDev @ react-dom.development.js:237
invokeGuardedCallback @ react-dom.development.js:292
flushPassiveEffectsImpl @ react-dom.development.js:22853
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushPassiveEffects @ react-dom.development.js:22820
performSyncWorkOnRoot @ react-dom.development.js:21737
(anonymous) @ react-dom.development.js:11089
unstable_runWithPriority @ scheduler.development.js:653
runWithPriority$1 @ react-dom.development.js:11039
flushSyncCallbackQueueImpl @ react-dom.development.js:11084
flushSyncCallbackQueue @ react-dom.development.js:11072
batchedUpdates$1 @ react-dom.development.js:21862
notify @ Subscription.js:19
notifyNestedSubs @ Subscription.js:92
handleChangeWrapper @ Subscription.js:97
dispatch @ redux.js:222
e @ VM347:1
(anonymous) @ index.js:11
dispatch @ VM347:1
(anonymous) @ ExportProjectActions.tsx:31
method @ SignalRHub.tsx:45
(anonymous) @ HubConnection.ts:634
HubConnection.invokeClientMethod @ HubConnection.ts:634
HubConnection.processIncomingData @ HubConnection.ts:530
HubConnection.connection.onreceive @ HubConnection.ts:102
webSocket.onmessage @ WebSocketTransport.ts:94

I believe that's resolved now.

@lgtm-com
Copy link

lgtm-com bot commented Nov 23, 2020

This pull request introduces 1 alert when merging 6f4db7f into 235c91c - view on LGTM.com

new alerts:

  • 1 for Rethrowing exception variable

@jasonleenaylor
Copy link
Contributor


Backend/Controllers/LiftController.cs, line 241 at r19 (raw file):

                return new OkObjectResult(projectId);
            }
            catch

Better to catch(Exception e) and throw e;

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 of 29 files reviewed, 1 unresolved discussion (waiting on @jasonleenaylor and @johnthagen)


Backend/Controllers/LiftController.cs, line 241 at r19 (raw file):

Previously, jasonleenaylor (Jason Naylor) wrote…

Better to catch(Exception e) and throw e;

That's what I'd done at first, but LGTM said it's bad practice, breaking call-stacks, and suggested this format. I assumed this way implicitly threw the error it caught.

@imnasnainaec imnasnainaec marked this pull request as ready for review November 23, 2020 21:53
@jasonleenaylor
Copy link
Contributor


Backend/Controllers/LiftController.cs, line 241 at r19 (raw file):

Previously, imnasnainaec (D. Ror.) wrote…

That's what I'd done at first, but LGTM said it's bad practice, breaking call-stacks, and suggested this format. I assumed this way implicitly threw the error it caught.

So it does...lgtm taught me something new today.

@jasonleenaylor
Copy link
Contributor


Backend/Services/LiftApiServices.cs, line 92 at r19 (raw file):

 private readonly string inProgress = "IN_PROGRESS";

For style purposes make this a const and move it to the top of the file. Unless LGTM doesn't like that either. ;)

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewable status: 6 of 29 files reviewed, 1 unresolved discussion (waiting on @jasonleenaylor and @johnthagen)


Backend/Services/LiftApiServices.cs, line 92 at r19 (raw file):

Previously, jasonleenaylor (Jason Naylor) wrote…
 private readonly string inProgress = "IN_PROGRESS";

For style purposes make this a const and move it to the top of the file. Unless LGTM doesn't like that either. ;)

Moved to top of class.

Copy link
Contributor

@jasonleenaylor jasonleenaylor left a comment

Choose a reason for hiding this comment

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

Reviewed 9 of 24 files at r2, 1 of 4 files at r4, 1 of 6 files at r14, 1 of 2 files at r15, 1 of 3 files at r16, 1 of 3 files at r17, 7 of 9 files at r18, 2 of 2 files at r19, 1 of 1 files at r20.
Dismissed @johnthagen from a discussion.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved


src/components/ProjectExport/ExportProjectButton.tsx, line 16 at r20 (raw file):

 utto

Colony collapse disorder must be affecting your code comments.

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewed 11 of 24 files at r2, 1 of 4 files at r4, 2 of 2 files at r6, 2 of 4 files at r7, 1 of 6 files at r14, 1 of 2 files at r15, 1 of 3 files at r16, 1 of 3 files at r17, 5 of 9 files at r18, 2 of 2 files at r19, 1 of 1 files at r20, 1 of 1 files at r21.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

Copy link
Collaborator Author

@imnasnainaec imnasnainaec left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r22.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved

@imnasnainaec imnasnainaec merged commit 0515bde into master Nov 24, 2020
@imnasnainaec imnasnainaec deleted the signalr branch November 24, 2020 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants