Begin listening for events on the operation. This method keeps track of how many "complete" listeners are registered and removed, making sure polling is handled automatically.
As long as there is one active "complete" listener, the connection is open. When there are no more listeners, the polling stops.
Returns
Type
Description
void
poll_(callback)
protectedpoll_(callback:MetadataCallback):void;
Poll for a status update. Returns null for an incomplete status, and metadata for a complete status.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[],[],null,["# Class Operation (6.0.0)\n\nVersion latestkeyboard_arrow_down\n\n- [6.0.0 (latest)](/nodejs/docs/reference/common/latest/common/operation)\n- [5.0.2](/nodejs/docs/reference/common/5.0.2/common/operation)\n- [4.0.3](/nodejs/docs/reference/common/4.0.3/common/operation)\n- [3.10.0](/nodejs/docs/reference/common/3.10.0/common/operation)\n- [3.9.0](/nodejs/docs/reference/common/3.9.0/common/operation)\n- [3.8.1](/nodejs/docs/reference/common/3.8.1/common/operation)\n- [3.7.4](/nodejs/docs/reference/common/3.7.4/common/operation) \n\nInheritance\n-----------\n\nServiceObject\\\u003cT\\\u003e \\\u003e Operation\n\nPackage\n-------\n\n[@google-cloud/common](../overview.html)\n\nConstructors\n------------\n\n### (constructor)(config)\n\n constructor(config: ServiceObjectConfig);\n\nAn Operation object allows you to interact with APIs that take longer to process things.\n\nmodule:common/operation\n\nProperties\n----------\n\n### completeListeners\n\n completeListeners: number;\n\n### hasActiveListeners\n\n hasActiveListeners: boolean;\n\nMethods\n-------\n\n### listenForEvents_()\n\n protected listenForEvents_(): void;\n\nBegin listening for events on the operation. This method keeps track of how many \"complete\" listeners are registered and removed, making sure polling is handled automatically.\n\nAs long as there is one active \"complete\" listener, the connection is open. When there are no more listeners, the polling stops.\n\n### poll_(callback)\n\n protected poll_(callback: MetadataCallback): void;\n\nPoll for a status update. Returns null for an incomplete status, and metadata for a complete status.\n\n### promise()\n\n promise(): Promise\u003cunknown\u003e;\n\nWraps the `complete` and `error` events in a Promise.\n\n{Promise}\n\n### startPolling_()\n\n protected startPolling_(): Promise\u003cvoid\u003e;\n\nPoll `getMetadata` to check the operation's status. This runs a loop to ping the API on an interval.\n\nNote: This method is automatically called once a \"complete\" event handler is registered on the operation."]]