Skip to content

Commit 74aeb44

Browse files
authored
line chart: improve worker doc and check for assumption (#4416)
Internally, due to conformance reasons, we cannot support a relative path for the worker resource. As such, we are now modifying the contract and accompany the change with a check.
1 parent 74d5d51 commit 74aeb44

File tree

1 file changed

+10
-5
lines changed
  • tensorboard/webapp/widgets/line_chart_v2/lib

1 file changed

+10
-5
lines changed

tensorboard/webapp/widgets/line_chart_v2/lib/worker.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ limitations under the License.
1818
*
1919
* This module exists to conform to internal requirements.
2020
*
21-
* @param workerResourcePath URL pathanme to the JavaScript resource served by
22-
* TensorBoard. TensorBoard disallows fetching JavaScript resources from a differnt
23-
* origin.
21+
* @param workerJsFilename Worker JavaScript resource file name. Exact resource path
22+
* depends on context. It can be relative or absolute depending on a app and its
23+
* configuration. Please see the internal version of this module for details.
2424
*/
25-
export function getWorker(workerResourcePath: string): Worker {
26-
return new Worker(workerResourcePath);
25+
export function getWorker(workerJsFilename: string): Worker {
26+
if (workerJsFilename.includes('/')) {
27+
throw new RangeError(
28+
'Worker factory only allows file name and no resource path.'
29+
);
30+
}
31+
return new Worker(workerJsFilename);
2732
}

0 commit comments

Comments
 (0)