async function run()

in src/k8s/common/streamResult/index.ts [20:43]


  async function run() {
    try {
      const item = await ApiProxy.request(`${url}/${name}`);
      if (isCancelled) return;
      cb(item);

      const fieldSelector = encodeURIComponent(`metadata.name=${name}`);
      const watchUrl = `${url}?watch=1&fieldSelector=${fieldSelector}`;

      socket = ApiProxy.stream(
        watchUrl,
        (x) => {
          const currentVersion = parseInt(item.metadata.resourceVersion, 10);
          const newVersion = parseInt(x.object.metadata.resourceVersion, 10);
          if (currentVersion < newVersion) {
            cb(x.object);
          }
        },
        { isJson: true }
      );
    } catch (err) {
      if (errCb) errCb(err as ApiError, cancel);
    }
  }