dgp1130 / rules_prerender

A Bazel rule set for prerending HTML pages.
13 stars 0 forks source link

`prerender_multi_page()` should fail if the same path is given multiple times #23

Closed dgp1130 closed 3 years ago

dgp1130 commented 3 years ago

Consider the following renderer program:

import { PrerenderResource } from 'rules_prerender';

export default function* (): Iterable<PrerenderResource> {
    yield PrerenderResource.of('/foo.txt', 'Hello, Foo!');
    yield PrerenderResource.of('/foo.txt', 'Hello, Bar!');
}

Note that the second PrerenderResource writes to the same /foo.txt file, but with different contents. Currently, the multi-renderer just writes /foo.txt twice and the last one wins. If users generate these files in parallel, this could result in a possible race condition which causes non-hermetic builds.

If this ever happens it is almost certainly a bug in user code. The multi-renderer should check for this case as each resource is provided and fail if the same path is given twice.