files/en-us/web/api/gpucommandencoder/finish/index.md
{{APIRef("WebGPU API")}}{{SecureContext_Header}}{{AvailableInWorkers}}
The finish() method of the
{{domxref("GPUCommandEncoder")}} interface completes recording of the command sequence encoded on this GPUCommandEncoder, returning a corresponding {{domxref("GPUCommandBuffer")}}.
finish()
finish(descriptor)
descriptor {{optional_inline}}
label {{optional_inline}}
A {{domxref("GPUCommandBuffer")}} object instance.
The following criteria must be met when calling finish(), otherwise a {{domxref("GPUValidationError")}} is generated and the {{domxref("GPUCommandEncoder")}} becomes invalid:
end()).finish() called on it (in which case it cannot be used to encode any more commands).// …
const commandBuffer = commandEncoder.finish();
device.queue.submit([commandBuffer]);
// …
{{Specifications}}
{{Compat}}