nds-org / workbench-webui

Web UI for the Workbench platform
0 stars 1 forks source link

fix: async behavior when creating/updating a spec #23

Closed bodom0015 closed 1 year ago

bodom0015 commented 1 year ago

Problem

When saving a new appspec, the UI throws the following error:

# 404 error resulting from existence check
>     GET https://kubernetes.docker.internal/api/v1/services/yay 404
sendRequest @ request.ts:131
await in sendRequest (async)

# I thought that this "uncaught" error would just return undefined.. apparently that is not the case
>     Uncaught (in promise) Error: Not found - spec key not found
    at catchErrors (request.ts:175:1)
    at request (request.ts:203:1)
    at async AppSpecService.getServiceById (AppSpecService.ts:96:1)
    at async saveSpec (AddEditSpec.tsx:329:1)
catchErrors @ request.ts:175
request @ request.ts:203
await in request (async)
onClick @ AddEditSpec.tsx:375 

# This only appears in development mode, but "process" is usually a server-side thing...
>      Uncaught ReferenceError: process is not defined

Apparently we need a .catch clause when async/await will hit an error

Approach

How to Test

Prerequisites:

Test Steps:

  1. Checkout this branch and run locally: make compile
  2. Login to Workbench WebUI via Keycloak user
  3. Navigate to My Catalog
  4. Click the "Create New Application" button
  5. Enter spec details:
    • key: anything
    • image: something
    • ports: 8888
  6. Click Save
    • You should be redirected back to the My Catalog view
    • You should see your new application now appears in the list