ampproject / ampproject/amphtml

amp-script in amp-list creating new Worker

Open
#36,148 4 comments 0 reactions 0 assignees View on GitHub
Stale Type: Bug
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

I am doing a project for an important client collaborating with brands like
(elle, inStyle, marie claire, Bazaar) based on amp.

The project allows shopping in many fashion related stores.
Unfortunately I have encountered a problem that I am unable to solve that
is holding up deployment.

Namely, I am using amp-script **(8Kb script)** inside the amp-list.
The problem is that with every amp-list refresh a new webWorker is created. The
same happens when opening an amp-modal with the amp-script. The problem is
that even though the used script is only 8Kb, after several interactions
due to running web-workers the limit of the amp script is exceeded and
there are several outdated web-workers in the background.

Is there any way to terminate its own webWorker in amp-script or solve this
problem with creating new WebWorkers on amp-list refresh?

The example of problem is available on : https://calm-desert-070c00903.azurestaticapps.net/elle
when adding to cart couple of product or opening the basket

This is very important for the completion of the project.

I would appreciate your answer.

### Reproduction Steps

1. Place amp script ( with size under limitation) inside amp-list or modal
2. Every amp-list refresh new amp-script is initialized
3. After few refreshing or interactions amp script size exceeded

### Relevant Logs

```shell
[amp-script] Maximum total script size exceeded (150000). amp-script[src="https://iine.devbuild.pl/js/mkt-main.js"].js is disabled. See https://amp.dev/documentation/components/amp-script/#size-of-javascript-code.
```

### Browser(s) Affected

Chrome, Firefox, Safari, Edge, UC Browser

### OS(s) Affected

All

### Device(s) Affected

All

### AMP Version Affected

_No response_

Contributor guide

Open the contributing guide

Research direction

Start with the linked reproduction and reproduce the issue by refreshing amp-list and opening amp-modal while using the 8 KB amp-script. Inspect the amp-script initialization path associated with amp-list and modal interactions, then verify that repeated interactions no longer accumulate workers or trigger the maximum total script size error.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
frontend, web-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.