Skip to content

The component didn't check if the feature id is empty, causing useless network requests #80

@shc0743

Description

@shc0743

As the title said, the component didn't check if the feature id is empty, causing an undefined request sent in dynamic-created scenes.

Image

Summary

  • There is no empty-value check before the network request
  • The component sends the request as soon as it was mounted
  • The problems above caused an incorrect request sent, like https://api.webstatus.dev/v1/features/undefined

This problem influences when the component is created dynamically (e.g. using reactive framework like Vue). In these case, the feature-id is delayed to be set, causing the problem.

Online demo

Steps to reproduce

Online reproduce

  1. Open the online demo above
  2. wait for data load
  3. open DevTools
  4. pick a feature from the list
  5. You will see the failed (or cancelled) request in the Network panel.

Offline (minimal) reproduce

  1. Import the library (probably from a CDN, or you can also use npm)
  2. Open DevTools
  3. Run JavaScript: document.body.append(document.createElement('baseline-status'))
  4. You will see the request in the Network panel.

Expected behavior

The feature-id attribute should be checked whether it is empty or not

Actual behavior

The request was sent without checking if the value is falsy

Environment

baseline-status v1.1.1, sri=sha256-FEtothNmbgdolsd7g8pRU1Ws5e2jK4C+QUCi9MpY8G0=

Additional information

An online demo could be found at https://myappsbucket.apps.furieau.com/webstatic/standalone/Baseline%E7%8A%B6%E6%80%81%E6%9F%A5%E7%9C%8B%E5%99%A8.html


Update: There seemed to be a check in the file, however the problem still exists. Maybe this is a task-queue related problem? However I'm not very familiar about the lit framework, so it is hard for me to find out the exact reason. :( Sorry for the inconvenient I made

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions