Skip to content
code google google workspace apps script v8 wintercg javascript runtime

Apps Script V8 Runtime Limitations

By , Google Workspace alum Published 1 min read

Last verified in 2024. APIs or CLI flags may have changed; browse newer Apps Script guides.

Google Apps Script is a cloud-based scripting platform that lets you automate tasks, customize functions, and build solutions within Google Workspace using JavaScript and the V8 runtime. V8 is the JavaScript engine that powers Google Chrome and Node.js. However, the runtime has some limitations that you should be aware of when developing Apps Script projects and not all JavaScript functions and interfaces are supported.

WinterCG Minimum Common Web Platform API

This is similar to the challenges being addressed by the Web-interoperable Runtimes Community Group (WinterCG) project, which aims to improve API interoperability across different JavaScript runtimes. The WinterCG has a draft Minimum Common Web Platform API proposal that aims to define a minimum set of APIs that should be available in all JavaScript runtimes. I took this draft and tested the APIs in the Apps Script V8 runtime to see which ones are supported and which ones are not. Below are the results generated by the script:

JavaScript APIs and availability in Apps Script V8

JavaScript APIAvailableError
AbortControllerNoAbortController is not defined
AbortSignalNoAbortSignal is not defined
atobNoatob is not defined
BlobNoBlob is not defined
btoaNobtoa is not defined
ByteLengthQueuingStrategyNoByteLengthQueuingStrategy is not defined
clearIntervalNoclearInterval is not defined
clearTimeoutNoclearTimeout is not defined
CompressionStreamNoCompressionStream is not defined
consoleYes-
CountQueuingStrategyNoCountQueuingStrategy is not defined
cryptoNocrypto is not defined
CryptoNoCrypto is not defined
CryptoKeyNoCryptoKey is not defined
DecompressionStreamNoDecompressionStream is not defined
DOMExceptionNoDOMException is not defined
EventNoEvent is not defined
EventTargetNoEventTarget is not defined
fetchNofetch is not defined
FileNoFile is not defined
FormDataNoFormData is not defined
HeadersNoHeaders is not defined
navigator.userAgentNonavigator is not defined
performance.nowNoperformance is not defined
performance.timeOriginNoperformance is not defined
queueMicrotaskNoqueueMicrotask is not defined
ReadableByteStreamControllerNoReadableByteStreamController is not defined
ReadableStreamNoReadableStream is not defined
ReadableStreamBYOBReaderNoReadableStreamBYOBReader is not defined
ReadableStreamBYOBRequestNoReadableStreamBYOBRequest is not defined
ReadableStreamDefaultControllerNoReadableStreamDefaultController is not defined
ReadableStreamDefaultReaderNoReadableStreamDefaultReader is not defined
RequestNoRequest is not defined
ResponseNoResponse is not defined
setIntervalNosetInterval is not defined
setTimeoutNosetTimeout is not defined
structuredCloneNostructuredClone is not defined
SubtleCryptoNoSubtleCrypto is not defined
TextDecoderNoTextDecoder is not defined
TextDecoderStreamNoTextDecoderStream is not defined
TextEncoderNoTextEncoder is not defined
TextEncoderStreamNoTextEncoderStream is not defined
TransformStreamNoTransformStream is not defined
TransformStreamDefaultControllerNoTransformStreamDefaultController is not defined
URLNoURL is not defined
URLSearchParamsNoURLSearchParams is not defined
WebAssembly.compileYes-
WebAssembly.compileStreamingNoWebAssembly.compileStreaming is not a function
WebAssembly.GlobalYes-
WebAssembly.InstanceYes-
WebAssembly.instantiateYes-
WebAssembly.instantiateStreamingNoWebAssembly.instantiateStreaming is not a function
WebAssembly.MemoryYes-
WebAssembly.ModuleYes-
WebAssembly.TableYes-
WebAssembly.validateYes-
WritableStreamNoWritableStream is not defined
WritableStreamDefaultControllerNoWritableStreamDefaultController is not defined

Runtime workarounds

For some APIs there is an Apps Script specific alternative. For example, the fetch API is not available in Apps Script, but you can use the UrlFetchApp service instead.

// fetch('https://api.example.com/data') UrlFetchApp.fetch("https://api.example.com/data");

Other examples such as setTimeout and setInterval are not available in Apps Script, but you can use the Utilities.sleep method.

// setTimeout(() => console.log('Hello'), 1000) Utilities.sleep(1000); console.log("Hello");

It is also possible to use polyfills or workarounds to achieve the same functionality. An example of this is the TextEncoder and TextDecoder interfaces, which are not available in Apps Script, but you can use the util npm package to achieve the same functionality with some manual setup or bundling outside of Apps Script.

One thing to keep in mind is that streaming functionality is not available in Apps Script and there really isn’t a good workaround for this. However, there is asynchronous support which is needed for the WebAssembly interface!

Frequently asked questions

Are all JavaScript APIs available in Apps Script?

No, not all standard JavaScript APIs are supported in Apps Script's V8 runtime. You'll encounter limitations, and some common Web APIs won't be available.

Is the fetch API available in Apps Script?

No, the standard fetch API isn't in Apps Script. Instead, use UrlFetchApp to make external requests.

How can I create delays or scheduled tasks in Apps Script?

setTimeout and setInterval are unavailable. For simple pauses, use Utilities.sleep(). For recurring tasks, installable triggers are the way to go.

Are TextEncoder and TextDecoder available in Apps Script?

No, TextEncoder and TextDecoder aren't native. I typically use polyfills or bundle external libraries, like the util npm package, to get this functionality.

Is streaming supported in Apps Script?

Unfortunately, streaming isn't supported in Apps Script, and there isn't a good workaround for this limitation.