| 10:07 | <nicolo-ribaudo> | guybedford I have another question about ModuleSources across workers. Consider this example:
- you open your webpage
- you serve a file
console.log(1) at http://localhost:8080/a.js
- you do
const source = await import.source("http://localhost:8080/a.js") in the main thread
- you change
http://localhost:8080/a.js to instead serve console.log(2)
- you do
await import(source) in the main thread
- you spawn a worker
- in the worker, you do
await import("http://localhost:8080/a.js")
- you postMessage
source from the main thread to the worker
- in the worker, you do
await import(source)
(a) What does the main thread log? (b) What does the worker log? (c) Does moving step 7 to the end change what the worker logs?
|
| 10:45 | <Jack Works> | my intuition is we can leave that implementation defined unless there are some editorial problems |
| 10:47 | <littledan> | By implementation defined, do you mean host defined, so like HTML would have a particular answer? |
| 10:47 | <littledan> | How do you think html should answer these? |
| 10:50 | <Jack Works> | what do browsers do today? we can already test if the main thread shares the module cache with workers |
| 10:50 | <Jack Works> | I would prefer keeping the current behavior unless there is a good reason to change it. |
| 10:52 | <Jack Works> | and if they don't share the module cache today, I would answer the question above like this (a) 1 (b) 2 (c) yes? |
| 10:54 | <nicolo-ribaudo> | Today browsers log 1 and 2 (I only tested Chrome). For (c), you mean yes because it would log 1 both times? |
| 10:54 | <nicolo-ribaudo> | my intuition is we can leave that implementation defined unless there are some editorial problems Well yes host defined, but it's still on us to propose to HTML what the behaviour should be :) |
| 11:15 | <Jack Works> | Today browsers log 1 and 2 (I only tested Chrome). For (c), you mean yes because it would log 1 both times? I think transfer the stale module source to the worker should fill the module cache so it only logs 1, no more network fetch, but I'm open to it |
| 11:17 | <nicolo-ribaudo> | I think that might be the best approach |
| 11:17 | <nicolo-ribaudo> | Something I dislike about the races though, is that all the static analysis on module sources in unreliable |
| 11:18 | <nicolo-ribaudo> | i.e. if instead of console.log those examples were export let a = 1 and export let b = 1, then the result of line 9 doesn't have any a export but source.exports contains a |
| 15:00 | <nicolo-ribaudo> | I'll be a few minutes late |
| 15:08 | <Luca Casonato> |
Something I dislike about the races though, is that all the static analysis on module sources in unreliable
But not within a single realm - it's only unreliable cross-realm / cross-agent
|
| 16:41 | <guybedford> | We discussed this today as having four possible semantics (and please share if you can think of more):
- First wins: As Nicolo discussed in the original description, where the potentially different cached source and instance content is used.
- Replace: Transfer of a module source into a new realm, acts as a registry set semantic, which if it is exactly the same module source coalesces with the existing source and instance, but otherwise replaces the module at that key in the registry and refreshes the instance slot.
- New key: Transfer of a module source, either coalesces or when the key has another source, causes the key itself to be updated.
- Throw: When transferring a module source, if there is already a source at its key and it does not exactly match the source transferred, throw when attempting to import the source.
We had some lively discussions today, which we will pick up again next week.
|
| 16:43 | <nicolo-ribaudo> | guybedford I have another question about ModuleSources across workers. Consider this example:
- you open your webpage
- you serve a file
console.log(1) at http://localhost:8080/a.js
- you do
const source = await import.source("http://localhost:8080/a.js") in the main thread
- you change
http://localhost:8080/a.js to instead serve console.log(2)
- you do
await import(source) in the main thread
- you spawn a worker
- in the worker, you do
await import("http://localhost:8080/a.js")
- you postMessage
source from the main thread to the worker
- in the worker, you do
await import(source)
(a) What does the main thread log? (b) What does the worker log? (c) Does moving step 7 to the end change what the worker logs?
Guy's message is in response to this |