( priorityLevel: PriorityLevel, postTaskPriority: PostTaskPriorityLevel, node: CallbackNode, callback: SchedulerCallback<T>, )
| 115 | } |
| 116 | |
| 117 | function runTask<T>( |
| 118 | priorityLevel: PriorityLevel, |
| 119 | postTaskPriority: PostTaskPriorityLevel, |
| 120 | node: CallbackNode, |
| 121 | callback: SchedulerCallback<T>, |
| 122 | ) { |
| 123 | deadline = getCurrentTime() + yieldInterval; |
| 124 | try { |
| 125 | currentPriorityLevel_DEPRECATED = priorityLevel; |
| 126 | const didTimeout_DEPRECATED = false; |
| 127 | const result = callback(didTimeout_DEPRECATED); |
| 128 | if (typeof result === 'function') { |
| 129 | // Assume this is a continuation |
| 130 | const continuation: SchedulerCallback<T> = (result: any); |
| 131 | const continuationOptions = { |
| 132 | signal: node._controller.signal, |
| 133 | }; |
| 134 | |
| 135 | const nextTask = runTask.bind( |
| 136 | null, |
| 137 | priorityLevel, |
| 138 | postTaskPriority, |
| 139 | node, |
| 140 | continuation, |
| 141 | ); |
| 142 | |
| 143 | if (scheduler.yield !== undefined) { |
| 144 | scheduler |
| 145 | .yield(continuationOptions) |
| 146 | .then(nextTask) |
| 147 | .catch(handleAbortError); |
| 148 | } else { |
| 149 | scheduler |
| 150 | .postTask(nextTask, continuationOptions) |
| 151 | .catch(handleAbortError); |
| 152 | } |
| 153 | } |
| 154 | } catch (error) { |
| 155 | // We're inside a `postTask` promise. If we don't handle this error, then it |
| 156 | // will trigger an "Unhandled promise rejection" error. We don't want that, |
| 157 | // but we do want the default error reporting behavior that normal |
| 158 | // (non-Promise) tasks get for unhandled errors. |
| 159 | // |
| 160 | // So we'll re-throw the error inside a regular browser task. |
| 161 | setTimeout(() => { |
| 162 | throw error; |
| 163 | }); |
| 164 | } finally { |
| 165 | currentPriorityLevel_DEPRECATED = NormalPriority; |
| 166 | } |
| 167 | } |
| 168 | |
| 169 | function handleAbortError(error: any) { |
| 170 | // Abort errors are an implementation detail. We don't expose the |
nothing calls this directly
no test coverage detected