[{"data":1,"prerenderedAt":1270},["ShallowReactive",2],{"learn-doc-\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop\u002Ftask-queues":3,"learn-doc-topic-\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop":483,"lessons-\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop":514,"sidebar-course-\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop":1213,"i-lucide:chevron-down":1225,"i-lucide:search":1229,"i-lucide:sun":1231,"i-lucide:moon":1233,"i-lucide:arrow-right":1235,"i-lucide:menu":1237,"i-lucide:panel-left":1239,"i-lucide:chevron-right":1241,"i-lucide:arrow-left":1243,"i-lucide:corner-down-right":1245,"i-lucide:mail":1247,"i-simple-icons:x":1249,"i-simple-icons:linkedin":1251,"i-simple-icons:dribbble":1253,"i-simple-icons:github":1255,"sidebar-quiz-\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop":1257,"i-lucide:workflow":1258,"i-lucide:circle-check-big":1260,"i-lucide:printer":1262,"i-lucide:graduation-cap":1264,"i-lucide:book-marked":1266,"i-lucide:notebook-pen":1268},{"id":4,"title":5,"access":6,"body":7,"description":474,"extension":475,"lang":476,"meta":477,"navigation":127,"order":124,"partial":478,"path":479,"seo":480,"stem":481,"__hash__":482},"lessons\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop\u002F02.task-queues.md","Tasks and microtasks","free",{"type":8,"value":9,"toc":468},"minimark",[10,14,18,77,82,90,246,249,257,260,264,270,362,375,379,382,435,448,452,455,464],[11,12,5],"h1",{"id":13},"tasks-and-microtasks",[15,16,17],"p",{},"There is not one queue. There are two, and they are drained differently.",[19,20,21,37],"table",{},[22,23,24],"thead",{},[25,26,27,31,34],"tr",{},[28,29,30],"th",{},"Queue",[28,32,33],{},"Sources",[28,35,36],{},"Drained",[38,39,40,60],"tbody",{},[25,41,42,46,57],{},[43,44,45],"td",{},"Task (macrotask)",[43,47,48,52,53,56],{},[49,50,51],"code",{},"setTimeout",", ",[49,54,55],{},"setInterval",", I\u002FO, events",[43,58,59],{},"One per loop iteration",[25,61,62,65,74],{},[43,63,64],{},"Microtask",[43,66,67,68,52,71],{},"Promise callbacks, ",[49,69,70],{},"queueMicrotask",[49,72,73],{},"MutationObserver",[43,75,76],{},"Completely, after every task",[78,79,81],"h2",{"id":80},"the-rule","The rule",[15,83,84,85,89],{},"After the stack empties, the event loop drains ",[86,87,88],"strong",{},"the entire microtask queue"," before\ntaking the next task. Microtasks added while draining are also processed in the same\npass.",[91,92,97],"pre",{"className":93,"code":94,"language":95,"meta":96,"style":96},"language-js shiki shiki-themes github-dark-dimmed github-dark-dimmed","console.log('script start')\n\nsetTimeout(() => console.log('timeout'), 0)\n\nPromise.resolve()\n  .then(() => console.log('promise 1'))\n  .then(() => console.log('promise 2'))\n\nconsole.log('script end')\n","js","",[49,98,99,122,129,160,165,180,205,227,232],{"__ignoreMap":96},[100,101,104,108,112,115,119],"span",{"class":102,"line":103},"line",1,[100,105,107],{"class":106},"sM9_K","console.",[100,109,111],{"class":110},"s-wk_","log",[100,113,114],{"class":106},"(",[100,116,118],{"class":117},"szYpP","'script start'",[100,120,121],{"class":106},")\n",[100,123,125],{"class":102,"line":124},2,[100,126,128],{"emptyLinePlaceholder":127},true,"\n",[100,130,132,134,137,141,144,146,148,151,154,158],{"class":102,"line":131},3,[100,133,51],{"class":110},[100,135,136],{"class":106},"(() ",[100,138,140],{"class":139},"sEYkB","=>",[100,142,143],{"class":106}," console.",[100,145,111],{"class":110},[100,147,114],{"class":106},[100,149,150],{"class":117},"'timeout'",[100,152,153],{"class":106},"), ",[100,155,157],{"class":156},"sQdni","0",[100,159,121],{"class":106},[100,161,163],{"class":102,"line":162},4,[100,164,128],{"emptyLinePlaceholder":127},[100,166,168,171,174,177],{"class":102,"line":167},5,[100,169,170],{"class":156},"Promise",[100,172,173],{"class":106},".",[100,175,176],{"class":110},"resolve",[100,178,179],{"class":106},"()\n",[100,181,183,186,189,191,193,195,197,199,202],{"class":102,"line":182},6,[100,184,185],{"class":106},"  .",[100,187,188],{"class":110},"then",[100,190,136],{"class":106},[100,192,140],{"class":139},[100,194,143],{"class":106},[100,196,111],{"class":110},[100,198,114],{"class":106},[100,200,201],{"class":117},"'promise 1'",[100,203,204],{"class":106},"))\n",[100,206,208,210,212,214,216,218,220,222,225],{"class":102,"line":207},7,[100,209,185],{"class":106},[100,211,188],{"class":110},[100,213,136],{"class":106},[100,215,140],{"class":139},[100,217,143],{"class":106},[100,219,111],{"class":110},[100,221,114],{"class":106},[100,223,224],{"class":117},"'promise 2'",[100,226,204],{"class":106},[100,228,230],{"class":102,"line":229},8,[100,231,128],{"emptyLinePlaceholder":127},[100,233,235,237,239,241,244],{"class":102,"line":234},9,[100,236,107],{"class":106},[100,238,111],{"class":110},[100,240,114],{"class":106},[100,242,243],{"class":117},"'script end'",[100,245,121],{"class":106},[15,247,248],{},"Output:",[91,250,255],{"className":251,"code":253,"language":254,"meta":96},[252],"language-text","script start\nscript end\npromise 1\npromise 2\ntimeout\n","text",[49,256,253],{"__ignoreMap":96},[15,258,259],{},"Both promise callbacks run before the timeout, even though the timeout was scheduled\nfirst. They are microtasks; the timeout is a task.",[78,261,263],{"id":262},"await-is-a-microtask-boundary","await is a microtask boundary",[15,265,266,269],{},[49,267,268],{},"await"," suspends the function and schedules the remainder as a promise continuation:",[91,271,273],{"className":93,"code":272,"language":95,"meta":96,"style":96},"async function run() {\n  console.log('a')\n  await null \u002F\u002F still a microtask, even awaiting a non-promise\n  console.log('c')\n}\n\nrun()\nconsole.log('b')\n\u002F\u002F a, b, c\n",[49,274,275,289,303,315,328,333,337,344,357],{"__ignoreMap":96},[100,276,277,280,283,286],{"class":102,"line":103},[100,278,279],{"class":139},"async",[100,281,282],{"class":139}," function",[100,284,285],{"class":110}," run",[100,287,288],{"class":106},"() {\n",[100,290,291,294,296,298,301],{"class":102,"line":124},[100,292,293],{"class":106},"  console.",[100,295,111],{"class":110},[100,297,114],{"class":106},[100,299,300],{"class":117},"'a'",[100,302,121],{"class":106},[100,304,305,308,311],{"class":102,"line":131},[100,306,307],{"class":139},"  await",[100,309,310],{"class":156}," null",[100,312,314],{"class":313},"s0RzX"," \u002F\u002F still a microtask, even awaiting a non-promise\n",[100,316,317,319,321,323,326],{"class":102,"line":162},[100,318,293],{"class":106},[100,320,111],{"class":110},[100,322,114],{"class":106},[100,324,325],{"class":117},"'c'",[100,327,121],{"class":106},[100,329,330],{"class":102,"line":167},[100,331,332],{"class":106},"}\n",[100,334,335],{"class":102,"line":182},[100,336,128],{"emptyLinePlaceholder":127},[100,338,339,342],{"class":102,"line":207},[100,340,341],{"class":110},"run",[100,343,179],{"class":106},[100,345,346,348,350,352,355],{"class":102,"line":229},[100,347,107],{"class":106},[100,349,111],{"class":110},[100,351,114],{"class":106},[100,353,354],{"class":117},"'b'",[100,356,121],{"class":106},[100,358,359],{"class":102,"line":234},[100,360,361],{"class":313},"\u002F\u002F a, b, c\n",[15,363,364,367,368,370,371,374],{},[49,365,366],{},"await null"," does not skip the queue. Everything after the ",[49,369,268],{}," becomes a\nmicrotask, so the synchronous ",[49,372,373],{},"console.log('b')"," runs first.",[78,376,378],{"id":377},"starving-the-loop","Starving the loop",[15,380,381],{},"Because microtasks drain completely, a microtask that schedules another microtask\nforever prevents any task from ever running:",[91,383,385],{"className":93,"code":384,"language":95,"meta":96,"style":96},"function spin() {\n  Promise.resolve().then(spin)\n}\nspin()\n\u002F\u002F Timers never fire. Rendering never happens. The page is frozen —\n\u002F\u002F but the CPU profile looks like idle promise work, not a busy loop.\n",[49,386,387,397,414,418,425,430],{"__ignoreMap":96},[100,388,389,392,395],{"class":102,"line":103},[100,390,391],{"class":139},"function",[100,393,394],{"class":110}," spin",[100,396,288],{"class":106},[100,398,399,402,404,406,409,411],{"class":102,"line":124},[100,400,401],{"class":156},"  Promise",[100,403,173],{"class":106},[100,405,176],{"class":110},[100,407,408],{"class":106},"().",[100,410,188],{"class":110},[100,412,413],{"class":106},"(spin)\n",[100,415,416],{"class":102,"line":131},[100,417,332],{"class":106},[100,419,420,423],{"class":102,"line":162},[100,421,422],{"class":110},"spin",[100,424,179],{"class":106},[100,426,427],{"class":102,"line":167},[100,428,429],{"class":313},"\u002F\u002F Timers never fire. Rendering never happens. The page is frozen —\n",[100,431,432],{"class":102,"line":182},[100,433,434],{"class":313},"\u002F\u002F but the CPU profile looks like idle promise work, not a busy loop.\n",[436,437,438],"danger",{},[15,439,440,441,444,445,447],{},"This is worse than a ",[49,442,443],{},"while (true)"," loop, because it is harder to spot. The stack is\nshallow, each individual microtask is fast, and nothing looks obviously wrong. Use\n",[49,446,51],{}," rather than promise recursion for anything that repeats indefinitely.",[78,449,451],{"id":450},"rendering","Rendering",[15,453,454],{},"In a browser, rendering is neither a task nor a microtask — it happens between\ntasks, at most once per frame. Since microtasks drain before rendering, a long\nmicrotask chain delays paint just as effectively as blocking code.",[456,457,458],"tip",{},[15,459,460,463],{},[49,461,462],{},"requestAnimationFrame"," callbacks run just before paint, after microtasks. That is\nthe correct place for visual updates, and the wrong place for anything expensive.",[465,466,467],"style",{},"html pre.shiki code .sM9_K, html code.shiki .sM9_K{--shiki-default:#ADBAC7;--shiki-dark:#ADBAC7}html pre.shiki code .s-wk_, html code.shiki .s-wk_{--shiki-default:#DCBDFB;--shiki-dark:#DCBDFB}html pre.shiki code .szYpP, html code.shiki .szYpP{--shiki-default:#96D0FF;--shiki-dark:#96D0FF}html pre.shiki code .sEYkB, html code.shiki .sEYkB{--shiki-default:#F47067;--shiki-dark:#F47067}html pre.shiki code .sQdni, html code.shiki .sQdni{--shiki-default:#6CB6FF;--shiki-dark:#6CB6FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .s0RzX, html code.shiki .s0RzX{--shiki-default:#768390;--shiki-dark:#768390}",{"title":96,"searchDepth":131,"depth":131,"links":469},[470,471,472,473],{"id":80,"depth":124,"text":81},{"id":262,"depth":124,"text":263},{"id":377,"depth":124,"text":378},{"id":450,"depth":124,"text":451},"Two queues, different draining rules, and the ordering that follows.","md","en",{},false,"\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop\u002Ftask-queues",{"title":5,"description":474},"learn\u002Fen\u002Fcourses\u002Fevent-loop\u002F02.task-queues","Jzwld-KwT30H_KYGrTndaDQB3plJFyiXJ-0rWZCopTQ",{"id":484,"title":485,"access":6,"body":486,"description":490,"draft":478,"estimatedMinutes":491,"extension":475,"featured":127,"icon":492,"lang":476,"level":493,"meta":494,"navigation":127,"order":103,"path":495,"prerequisites":496,"resources":497,"seo":502,"sku":503,"stem":504,"subjects":505,"summary":507,"tags":508,"updated":512,"__hash__":513},"courses\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop\u002Findex.md","The event loop",{"type":8,"value":487,"toc":488},[],{"title":96,"searchDepth":131,"depth":131,"links":489},[],"Call stack, task queues and microtasks — why your code ran in that order.",30,"lucide:workflow","intermediate",{},"\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop",[],[498],{"label":499,"file":500,"access":6,"size":501},"Event loop reference card","js-event-loop-card.pdf","95 KB",{"title":485,"description":490},null,"learn\u002Fen\u002Fcourses\u002Fevent-loop\u002Findex",[506],"javascript","JavaScript runs on one thread with one call stack. Anything asynchronous is\nhanded to the host environment, which puts a callback in a queue when it is\nready. The event loop moves work from those queues onto the stack, but only\nwhen the stack is empty. Microtasks — promise continuations — drain completely\nbetween each task, which is why an await resolves before a setTimeout of zero.\nAlmost every ordering surprise in JavaScript follows from those rules.\n",[279,509,510,511],"promises","runtime","concurrency","2026-08-05","BOC7v_GWQoKJp-mEK6X_H0pY-0KcxkhIWnXKWsm8c9k",[515,875],{"id":516,"title":517,"access":6,"body":518,"description":869,"extension":475,"lang":476,"meta":870,"navigation":127,"order":103,"partial":478,"path":871,"seo":872,"stem":873,"__hash__":874},"lessons\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop\u002F01.call-stack.md","The call stack",{"type":8,"value":519,"toc":864},[520,523,526,607,614,618,621,624,681,687,691,699,709,768,773,777,780,849,861],[11,521,517],{"id":522},"the-call-stack",[15,524,525],{},"JavaScript has a single call stack. One thing executes at a time, and a function\nruns to completion before anything else gets a turn.",[91,527,529],{"className":93,"code":528,"language":95,"meta":96,"style":96},"function third() {\n  return 'done'\n}\nfunction second() {\n  return third()\n}\nfunction first() {\n  return second()\n}\n\nfirst()\n",[49,530,531,540,548,552,561,569,573,582,590,594,599],{"__ignoreMap":96},[100,532,533,535,538],{"class":102,"line":103},[100,534,391],{"class":139},[100,536,537],{"class":110}," third",[100,539,288],{"class":106},[100,541,542,545],{"class":102,"line":124},[100,543,544],{"class":139},"  return",[100,546,547],{"class":117}," 'done'\n",[100,549,550],{"class":102,"line":131},[100,551,332],{"class":106},[100,553,554,556,559],{"class":102,"line":162},[100,555,391],{"class":139},[100,557,558],{"class":110}," second",[100,560,288],{"class":106},[100,562,563,565,567],{"class":102,"line":167},[100,564,544],{"class":139},[100,566,537],{"class":110},[100,568,179],{"class":106},[100,570,571],{"class":102,"line":182},[100,572,332],{"class":106},[100,574,575,577,580],{"class":102,"line":207},[100,576,391],{"class":139},[100,578,579],{"class":110}," first",[100,581,288],{"class":106},[100,583,584,586,588],{"class":102,"line":229},[100,585,544],{"class":139},[100,587,558],{"class":110},[100,589,179],{"class":106},[100,591,592],{"class":102,"line":234},[100,593,332],{"class":106},[100,595,597],{"class":102,"line":596},10,[100,598,128],{"emptyLinePlaceholder":127},[100,600,602,605],{"class":102,"line":601},11,[100,603,604],{"class":110},"first",[100,606,179],{"class":106},[15,608,609,610,613],{},"The stack grows to ",[49,611,612],{},"first → second → third",", then unwinds. Nothing interleaves.",[78,615,617],{"id":616},"run-to-completion-is-a-guarantee","Run-to-completion is a guarantee",[15,619,620],{},"Once a function starts, no other JavaScript can run until it returns. This is why\nyou never need locks around a shared variable: no other code can observe an\nintermediate state.",[15,622,623],{},"It is also why one slow function freezes everything:",[91,625,627],{"className":93,"code":626,"language":95,"meta":96,"style":96},"const start = Date.now()\nwhile (Date.now() - start \u003C 5000) {}\n\u002F\u002F Nothing else runs for five seconds — no clicks, no timers, no rendering.\n",[49,628,629,648,676],{"__ignoreMap":96},[100,630,631,634,637,640,643,646],{"class":102,"line":103},[100,632,633],{"class":139},"const",[100,635,636],{"class":156}," start",[100,638,639],{"class":139}," =",[100,641,642],{"class":106}," Date.",[100,644,645],{"class":110},"now",[100,647,179],{"class":106},[100,649,650,653,656,658,661,664,667,670,673],{"class":102,"line":124},[100,651,652],{"class":139},"while",[100,654,655],{"class":106}," (Date.",[100,657,645],{"class":110},[100,659,660],{"class":106},"() ",[100,662,663],{"class":139},"-",[100,665,666],{"class":106}," start ",[100,668,669],{"class":139},"\u003C",[100,671,672],{"class":156}," 5000",[100,674,675],{"class":106},") {}\n",[100,677,678],{"class":102,"line":131},[100,679,680],{"class":313},"\u002F\u002F Nothing else runs for five seconds — no clicks, no timers, no rendering.\n",[682,683,684],"warning",{},[15,685,686],{},"\"Blocking the event loop\" is not a metaphor. On the main thread of a browser, a\nlong synchronous loop blocks rendering, input handling and every pending callback.\nThe tab is frozen for the duration, and the browser may offer to kill it.",[78,688,690],{"id":689},"where-async-work-actually-happens","Where async work actually happens",[15,692,693,694,698],{},"The runtime is single-threaded. The ",[695,696,697],"em",{},"environment"," around it is not.",[15,700,701,702,704,705,708],{},"When you call ",[49,703,51],{},", the timer is not JavaScript — it is the host. When you\ncall ",[49,706,707],{},"fetch",", the network request is handled by the browser's networking stack on\nanother thread. Your callback is simply registered.",[91,710,712],{"className":93,"code":711,"language":95,"meta":96,"style":96},"console.log('1')\nsetTimeout(() => console.log('3'), 0)\nconsole.log('2')\n\u002F\u002F 1, 2, 3\n",[49,713,714,727,750,763],{"__ignoreMap":96},[100,715,716,718,720,722,725],{"class":102,"line":103},[100,717,107],{"class":106},[100,719,111],{"class":110},[100,721,114],{"class":106},[100,723,724],{"class":117},"'1'",[100,726,121],{"class":106},[100,728,729,731,733,735,737,739,741,744,746,748],{"class":102,"line":124},[100,730,51],{"class":110},[100,732,136],{"class":106},[100,734,140],{"class":139},[100,736,143],{"class":106},[100,738,111],{"class":110},[100,740,114],{"class":106},[100,742,743],{"class":117},"'3'",[100,745,153],{"class":106},[100,747,157],{"class":156},[100,749,121],{"class":106},[100,751,752,754,756,758,761],{"class":102,"line":131},[100,753,107],{"class":106},[100,755,111],{"class":110},[100,757,114],{"class":106},[100,759,760],{"class":117},"'2'",[100,762,121],{"class":106},[100,764,765],{"class":102,"line":162},[100,766,767],{"class":313},"\u002F\u002F 1, 2, 3\n",[15,769,770,772],{},[49,771,51],{}," returns immediately. The callback is queued for later even with a zero\ndelay, because \"later\" means \"once the stack is empty\" — not \"in zero milliseconds\".",[78,774,776],{"id":775},"the-stack-in-a-stack-trace","The stack in a stack trace",[15,778,779],{},"An error captures the stack at the moment it is thrown. In async code, the stack\nyou get is the one at callback time, not at scheduling time:",[91,781,783],{"className":93,"code":782,"language":95,"meta":96,"style":96},"function schedule() {\n  setTimeout(() => {\n    throw new Error('boom')\n  }, 0)\n}\nschedule()\n\u002F\u002F The trace shows the timer callback. `schedule` is long gone.\n",[49,784,785,794,806,824,833,837,844],{"__ignoreMap":96},[100,786,787,789,792],{"class":102,"line":103},[100,788,391],{"class":139},[100,790,791],{"class":110}," schedule",[100,793,288],{"class":106},[100,795,796,799,801,803],{"class":102,"line":124},[100,797,798],{"class":110},"  setTimeout",[100,800,136],{"class":106},[100,802,140],{"class":139},[100,804,805],{"class":106}," {\n",[100,807,808,811,814,817,819,822],{"class":102,"line":131},[100,809,810],{"class":139},"    throw",[100,812,813],{"class":139}," new",[100,815,816],{"class":110}," Error",[100,818,114],{"class":106},[100,820,821],{"class":117},"'boom'",[100,823,121],{"class":106},[100,825,826,829,831],{"class":102,"line":162},[100,827,828],{"class":106},"  }, ",[100,830,157],{"class":156},[100,832,121],{"class":106},[100,834,835],{"class":102,"line":167},[100,836,332],{"class":106},[100,838,839,842],{"class":102,"line":182},[100,840,841],{"class":110},"schedule",[100,843,179],{"class":106},[100,845,846],{"class":102,"line":207},[100,847,848],{"class":313},"\u002F\u002F The trace shows the timer callback. `schedule` is long gone.\n",[15,850,851,852,854,855,857,858,860],{},"Modern engines reconstruct async stack traces across ",[49,853,268],{}," boundaries, which is\none practical reason to prefer ",[49,856,279],{},"\u002F",[49,859,268],{}," over raw callbacks.",[465,862,863],{},"html pre.shiki code .sEYkB, html code.shiki .sEYkB{--shiki-default:#F47067;--shiki-dark:#F47067}html pre.shiki code .s-wk_, html code.shiki .s-wk_{--shiki-default:#DCBDFB;--shiki-dark:#DCBDFB}html pre.shiki code .sM9_K, html code.shiki .sM9_K{--shiki-default:#ADBAC7;--shiki-dark:#ADBAC7}html pre.shiki code .szYpP, html code.shiki .szYpP{--shiki-default:#96D0FF;--shiki-dark:#96D0FF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html pre.shiki code .sQdni, html code.shiki .sQdni{--shiki-default:#6CB6FF;--shiki-dark:#6CB6FF}html pre.shiki code .s0RzX, html code.shiki .s0RzX{--shiki-default:#768390;--shiki-dark:#768390}",{"title":96,"searchDepth":131,"depth":131,"links":865},[866,867,868],{"id":616,"depth":124,"text":617},{"id":689,"depth":124,"text":690},{"id":775,"depth":124,"text":776},"One thread, one stack, and what \"blocking\" actually blocks.",{},"\u002Flearn\u002Fen\u002Fcourses\u002Fevent-loop\u002Fcall-stack",{"title":517,"description":869},"learn\u002Fen\u002Fcourses\u002Fevent-loop\u002F01.call-stack","BiJN8dMZjgvIkocYL4WlAg539TRcbZZHnuwy9Hi7GFg",{"id":4,"title":5,"access":6,"body":876,"description":474,"extension":475,"lang":476,"meta":1211,"navigation":127,"order":124,"partial":478,"path":479,"seo":1212,"stem":481,"__hash__":482},{"type":8,"value":877,"toc":1205},[878,880,882,920,922,926,1038,1040,1045,1047,1049,1053,1129,1137,1139,1141,1185,1193,1195,1197,1203],[11,879,5],{"id":13},[15,881,17],{},[19,883,884,894],{},[22,885,886],{},[25,887,888,890,892],{},[28,889,30],{},[28,891,33],{},[28,893,36],{},[38,895,896,908],{},[25,897,898,900,906],{},[43,899,45],{},[43,901,902,52,904,56],{},[49,903,51],{},[49,905,55],{},[43,907,59],{},[25,909,910,912,918],{},[43,911,64],{},[43,913,67,914,52,916],{},[49,915,70],{},[49,917,73],{},[43,919,76],{},[78,921,81],{"id":80},[15,923,84,924,89],{},[86,925,88],{},[91,927,928],{"className":93,"code":94,"language":95,"meta":96,"style":96},[49,929,930,942,946,968,972,982,1002,1022,1026],{"__ignoreMap":96},[100,931,932,934,936,938,940],{"class":102,"line":103},[100,933,107],{"class":106},[100,935,111],{"class":110},[100,937,114],{"class":106},[100,939,118],{"class":117},[100,941,121],{"class":106},[100,943,944],{"class":102,"line":124},[100,945,128],{"emptyLinePlaceholder":127},[100,947,948,950,952,954,956,958,960,962,964,966],{"class":102,"line":131},[100,949,51],{"class":110},[100,951,136],{"class":106},[100,953,140],{"class":139},[100,955,143],{"class":106},[100,957,111],{"class":110},[100,959,114],{"class":106},[100,961,150],{"class":117},[100,963,153],{"class":106},[100,965,157],{"class":156},[100,967,121],{"class":106},[100,969,970],{"class":102,"line":162},[100,971,128],{"emptyLinePlaceholder":127},[100,973,974,976,978,980],{"class":102,"line":167},[100,975,170],{"class":156},[100,977,173],{"class":106},[100,979,176],{"class":110},[100,981,179],{"class":106},[100,983,984,986,988,990,992,994,996,998,1000],{"class":102,"line":182},[100,985,185],{"class":106},[100,987,188],{"class":110},[100,989,136],{"class":106},[100,991,140],{"class":139},[100,993,143],{"class":106},[100,995,111],{"class":110},[100,997,114],{"class":106},[100,999,201],{"class":117},[100,1001,204],{"class":106},[100,1003,1004,1006,1008,1010,1012,1014,1016,1018,1020],{"class":102,"line":207},[100,1005,185],{"class":106},[100,1007,188],{"class":110},[100,1009,136],{"class":106},[100,1011,140],{"class":139},[100,1013,143],{"class":106},[100,1015,111],{"class":110},[100,1017,114],{"class":106},[100,1019,224],{"class":117},[100,1021,204],{"class":106},[100,1023,1024],{"class":102,"line":229},[100,1025,128],{"emptyLinePlaceholder":127},[100,1027,1028,1030,1032,1034,1036],{"class":102,"line":234},[100,1029,107],{"class":106},[100,1031,111],{"class":110},[100,1033,114],{"class":106},[100,1035,243],{"class":117},[100,1037,121],{"class":106},[15,1039,248],{},[91,1041,1043],{"className":1042,"code":253,"language":254,"meta":96},[252],[49,1044,253],{"__ignoreMap":96},[15,1046,259],{},[78,1048,263],{"id":262},[15,1050,1051,269],{},[49,1052,268],{},[91,1054,1055],{"className":93,"code":272,"language":95,"meta":96,"style":96},[49,1056,1057,1067,1079,1087,1099,1103,1107,1113,1125],{"__ignoreMap":96},[100,1058,1059,1061,1063,1065],{"class":102,"line":103},[100,1060,279],{"class":139},[100,1062,282],{"class":139},[100,1064,285],{"class":110},[100,1066,288],{"class":106},[100,1068,1069,1071,1073,1075,1077],{"class":102,"line":124},[100,1070,293],{"class":106},[100,1072,111],{"class":110},[100,1074,114],{"class":106},[100,1076,300],{"class":117},[100,1078,121],{"class":106},[100,1080,1081,1083,1085],{"class":102,"line":131},[100,1082,307],{"class":139},[100,1084,310],{"class":156},[100,1086,314],{"class":313},[100,1088,1089,1091,1093,1095,1097],{"class":102,"line":162},[100,1090,293],{"class":106},[100,1092,111],{"class":110},[100,1094,114],{"class":106},[100,1096,325],{"class":117},[100,1098,121],{"class":106},[100,1100,1101],{"class":102,"line":167},[100,1102,332],{"class":106},[100,1104,1105],{"class":102,"line":182},[100,1106,128],{"emptyLinePlaceholder":127},[100,1108,1109,1111],{"class":102,"line":207},[100,1110,341],{"class":110},[100,1112,179],{"class":106},[100,1114,1115,1117,1119,1121,1123],{"class":102,"line":229},[100,1116,107],{"class":106},[100,1118,111],{"class":110},[100,1120,114],{"class":106},[100,1122,354],{"class":117},[100,1124,121],{"class":106},[100,1126,1127],{"class":102,"line":234},[100,1128,361],{"class":313},[15,1130,1131,367,1133,370,1135,374],{},[49,1132,366],{},[49,1134,268],{},[49,1136,373],{},[78,1138,378],{"id":377},[15,1140,381],{},[91,1142,1143],{"className":93,"code":384,"language":95,"meta":96,"style":96},[49,1144,1145,1153,1167,1171,1177,1181],{"__ignoreMap":96},[100,1146,1147,1149,1151],{"class":102,"line":103},[100,1148,391],{"class":139},[100,1150,394],{"class":110},[100,1152,288],{"class":106},[100,1154,1155,1157,1159,1161,1163,1165],{"class":102,"line":124},[100,1156,401],{"class":156},[100,1158,173],{"class":106},[100,1160,176],{"class":110},[100,1162,408],{"class":106},[100,1164,188],{"class":110},[100,1166,413],{"class":106},[100,1168,1169],{"class":102,"line":131},[100,1170,332],{"class":106},[100,1172,1173,1175],{"class":102,"line":162},[100,1174,422],{"class":110},[100,1176,179],{"class":106},[100,1178,1179],{"class":102,"line":167},[100,1180,429],{"class":313},[100,1182,1183],{"class":102,"line":182},[100,1184,434],{"class":313},[436,1186,1187],{},[15,1188,440,1189,444,1191,447],{},[49,1190,443],{},[49,1192,51],{},[78,1194,451],{"id":450},[15,1196,454],{},[456,1198,1199],{},[15,1200,1201,463],{},[49,1202,462],{},[465,1204,467],{},{"title":96,"searchDepth":131,"depth":131,"links":1206},[1207,1208,1209,1210],{"id":80,"depth":124,"text":81},{"id":262,"depth":124,"text":263},{"id":377,"depth":124,"text":378},{"id":450,"depth":124,"text":451},{},{"title":5,"description":474},{"id":484,"title":485,"access":6,"body":1214,"description":490,"draft":478,"estimatedMinutes":491,"extension":475,"featured":127,"icon":492,"lang":476,"level":493,"meta":1218,"navigation":127,"order":103,"path":495,"prerequisites":1219,"resources":1220,"seo":1222,"sku":503,"stem":504,"subjects":1223,"summary":507,"tags":1224,"updated":512,"__hash__":513},{"type":8,"value":1215,"toc":1216},[],{"title":96,"searchDepth":131,"depth":131,"links":1217},[],{},[],[1221],{"label":499,"file":500,"access":6,"size":501},{"title":485,"description":490},[506],[279,509,510,511],{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1228},0,24,"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m6 9l6 6l6-6\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1230},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"m21 21l-4.34-4.34\"\u002F>\u003Ccircle cx=\"11\" cy=\"11\" r=\"8\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1232},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Ccircle cx=\"12\" cy=\"12\" r=\"4\"\u002F>\u003Cpath d=\"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1234},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1236},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 12h14m-7-7l7 7l-7 7\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1238},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 5h16M4 12h16M4 19h16\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1240},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Crect width=\"18\" height=\"18\" x=\"3\" y=\"3\" rx=\"2\"\u002F>\u003Cpath d=\"M9 3v18\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1242},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m9 18l6-6l-6-6\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1244},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m12 19l-7-7l7-7m7 7H5\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1246},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"m15 10l5 5l-5 5\"\u002F>\u003Cpath d=\"M4 4v7a4 4 0 0 0 4 4h12\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1248},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"m22 7l-8.991 5.727a2 2 0 0 1-2.009 0L2 7\"\u002F>\u003Crect width=\"20\" height=\"16\" x=\"2\" y=\"4\" rx=\"2\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1250},"\u003Cpath fill=\"currentColor\" d=\"M14.234 10.162L22.977 0h-2.072l-7.591 8.824L7.251 0H.258l9.168 13.343L.258 24H2.33l8.016-9.318L16.749 24h6.993zm-2.837 3.299l-.929-1.329L3.076 1.56h3.182l5.965 8.532l.929 1.329l7.754 11.09h-3.182z\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1252,"hidden":127},"\u003Cpath fill=\"currentColor\" d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037c-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85c3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.06 2.06 0 0 1-2.063-2.065a2.064 2.064 0 1 1 2.063 2.065m1.782 13.019H3.555V9h3.564zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0z\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1254},"\u003Cpath fill=\"currentColor\" d=\"M12 24C5.385 24 0 18.615 0 12S5.385 0 12 0s12 5.385 12 12s-5.385 12-12 12m10.12-10.358c-.35-.11-3.17-.953-6.384-.438c1.34 3.684 1.887 6.684 1.992 7.308a10.28 10.28 0 0 0 4.395-6.87zm-6.115 7.808c-.153-.9-.75-4.032-2.19-7.77l-.066.02c-5.79 2.015-7.86 6.025-8.04 6.4a10.16 10.16 0 0 0 6.29 2.166c1.42 0 2.77-.29 4-.814zm-11.62-2.58c.232-.4 3.045-5.055 8.332-6.765q.202-.067.405-.12q-.392-.879-.832-1.74C7.17 11.775 2.206 11.71 1.756 11.7l-.004.312c0 2.633.998 5.037 2.634 6.855zm-2.42-8.955c.46.008 4.683.026 9.477-1.248a66 66 0 0 0-3.8-5.928a10.28 10.28 0 0 0-5.676 7.17zM9.6 2.052c.282.38 2.145 2.914 3.822 6c3.645-1.365 5.19-3.44 5.373-3.702A10.2 10.2 0 0 0 12 1.764c-.825 0-1.63.1-2.4.285zm10.335 3.483c-.218.29-1.935 2.493-5.724 4.04c.24.49.47.985.68 1.486c.08.18.15.36.22.53c3.41-.43 6.8.26 7.14.33c-.02-2.42-.88-4.64-2.31-6.38z\"\u002F>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1256},"\u003Cpath fill=\"currentColor\" d=\"M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\"\u002F>",{"course":495},{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1259},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Crect width=\"8\" height=\"8\" x=\"3\" y=\"3\" rx=\"2\"\u002F>\u003Cpath d=\"M7 11v4a2 2 0 0 0 2 2h4\"\u002F>\u003Crect width=\"8\" height=\"8\" x=\"13\" y=\"13\" rx=\"2\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1261},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M21.801 10A10 10 0 1 1 17 3.335\"\u002F>\u003Cpath d=\"m9 11l3 3L22 4\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1263},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6\"\u002F>\u003Crect width=\"12\" height=\"8\" x=\"6\" y=\"14\" rx=\"1\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1265},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M21.42 10.922a1 1 0 0 0-.019-1.838L12.83 5.18a2 2 0 0 0-1.66 0L2.6 9.08a1 1 0 0 0 0 1.832l8.57 3.908a2 2 0 0 0 1.66 0zM22 10v6\"\u002F>\u003Cpath d=\"M6 12.5V16a6 3 0 0 0 12 0v-3.5\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1267},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M10 2v8l3-3l3 3V2\"\u002F>\u003Cpath d=\"M4 19.5v-15A2.5 2.5 0 0 1 6.5 2H19a1 1 0 0 1 1 1v18a1 1 0 0 1-1 1H6.5a1 1 0 0 1 0-5H20\"\u002F>\u003C\u002Fg>",{"left":1226,"top":1226,"width":1227,"height":1227,"rotate":1226,"vFlip":478,"hFlip":478,"body":1269},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M13.4 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-7.4M2 6h4m-4 4h4m-4 4h4m-4 4h4\"\u002F>\u003Cpath d=\"M21.378 5.626a1 1 0 1 0-3.004-3.004l-5.01 5.012a2 2 0 0 0-.506.854l-.837 2.87a.5.5 0 0 0 .62.62l2.87-.837a2 2 0 0 0 .854-.506z\"\u002F>\u003C\u002Fg>",1787597895623]