Skip to content

Golden Retriever: ServiceWorker js file not transpiled into lib directory. #5945

@infovore

Description

@infovore

Initial checklist

  • I understand this is a bug report and questions should be posted in the Community Forum
  • I searched issues and couldn’t find anything (or linked relevant results below)

Link to runnable example

No response

Steps to reproduce

Using Golden Retriever and the S3 extension, configure an Uppy Uploader:

    const uppy = new Uppy()
      .use(Dashboard, { inline: true, target: uppyEl })
      .use(UppyS3, {
        endpoint: '/',
        shouldUseMultipart(file) {
          // use multipart for > 20mb files
          if (!file.size) {
            return false;
          }
          return file.size > 20 * 2 ** 20;
        }
      })
      .use(GoldenRetriever, { serviceWorker: true });

Add the service worker to your own service worker JS file as instructed in the Golden Retriever documentation:

import '@uppy/golden-retriever/lib/ServiceWorker';

Expected behavior

When restarting the browser after a period of time uploading, to simulate lost connection, the previous upload files should be displayed in the browser. Clicking "resume" should restart from the most recent chunk.

Actual behavior

Vite throws an error:

Missing "./lib/ServiceWorker" specifier in "@uppy/golden-retriever" package

And it's right: that file doesn't exist. All the Typescript in the package's src directory is appropriately transpiled, but src/ServiceWorker.js is not copied over. As a result, the Service Worker store does not function correctly - the file name and location is persisted, but the plugin cannot workout which chunk to recover from, and so just hangs (without an error message).

When I copy the contents of src/ServiceWorker.js into my Service Worker file, the resume functionality works correctly.

(Without anything in the Service Worker file, the files are found correctly, but does not know which chunk to resume from).

This feels like it could be resolved with a tsconfig change, or just renaming ServiceWorker.js to ServiceWorker.ts` and letting transpilation take hold.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions