Skip to content

Microtasks - #469

Merged
gabifs merged 3 commits into
javascript-tutorial:masterfrom
diogoosz:translate-microtask-queue
Nov 8, 2026
Merged

gabifs merged 3 commits into
javascript-tutorial:masterfrom
diogoosz:translate-microtask-queue

Conversation

@diogoosz

@diogoosz diogoosz commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

Tradução do artigo "Microtasks" para o português, incluindo a tradução do diagrama promiseQueue.svg.

Conforme comentado na #1.

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="430" height="185" viewBox="0 0 430 185"><defs><style>@import url(https://fonts.googleapis.com/css?family=Open+Sans:bold,italic,bolditalic%7CPT+Mono);@font-face{font-family:&apos;PT Mono&apos;;font-weight:700;font-style:normal;src:local(&apos;PT MonoBold&apos;),url(/font/PTMonoBold.woff2) format(&apos;woff2&apos;),url(/font/PTMonoBold.woff) format(&apos;woff&apos;),url(/font/PTMonoBold.ttf) format(&apos;truetype&apos;)}</style></defs><g id="promise" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="promiseQueue.svg"><text id="promise.then(handler" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="12" y="32" fill="#181717">promise</tspan> <tspan x="70.8" y="32" fill="#7E7C7B">.</tspan> <tspan x="79.2" y="32" fill="#181717">then</tspan> <tspan x="112.8" y="32" fill="#7E7C7B">(</tspan> <tspan x="121.2" y="32" fill="#181717">handler</tspan> <tspan x="180" y="32" fill="#7E7C7B">);</tspan> <tspan x="12" y="62" fill="#7E7C7B">...</tspan> <tspan x="12" y="92" fill="#000">alert</tspan> <tspan x="54" y="92" fill="#7E7C7B">(</tspan> <tspan x="62.4" y="92" fill="#478964">&quot;code finished&quot;</tspan> <tspan x="188.4" y="92" fill="#7E7C7B">);</tspan></text><path id="Line-2" stroke="#7E7C7B" stroke-dasharray="4,4" stroke-linecap="square" d="M4.5 112.5h226"/><text id="handler-enqueued" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="267" y="32">handler enqueued</tspan></text><text id="queued-handler-runs" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="11" y="153">queued handler runs</tspan></text><g id="noun_88566_cc-copy" fill="#7E7C7B" transform="translate(247 16)"><path id="Shape" d="M13.974 19.455c0-.342-.01-.748-.077-1.169a4.11 4.11 0 00-.649-1.653c-.174-.263-1.05-1.176-3.127-3.258a69.969 69.969 0 01-.372-.374l-.156-.159a5.561 5.561 0 01-.2-.217 2.823 2.823 0 01-.056-.07 1.504 1.504 0 01-.157-.226.652.652 0 01-.078-.2 1.729 1.729 0 01-.008-.263v-.031c.002-.106.005-.2.023-.27a.592.592 0 01.098-.186 3.43 3.43 0 01.225-.288c.076-.085.158-.168.244-.256l.065-.067.37-.372c2.078-2.083 2.955-2.997 3.13-3.26a4.106 4.106 0 00.649-1.653 7.57 7.57 0 00.076-1.169V2.261A.741.741 0 0014 2.075C14 .727 10.393 0 7 0S0 .727 0 2.075c0 .062.01.122.025.182v2.057c0 .322.01.745.077 1.17A4.116 4.116 0 00.75 7.135c.174.263 1.051 1.177 3.129 3.26.187.188.32.321.37.373l.062.063a3.43 3.43 0 01.471.547.59.59 0 01.099.186c.018.07.021.16.023.27v.03c.002.096.003.188-.008.263a.647.647 0 01-.078.2 1.515 1.515 0 01-.157.228 2.849 2.849 0 01-.153.177 6.914 6.914 0 01-.103.108l-.104.104c-3.288 3.29-3.486 3.59-3.551 3.688a4.114 4.114 0 00-.649 1.653 7.692 7.692 0 00-.077 1.17v2.239C.025 23.279 3.641 24 7 24c3.36 0 6.975-.721 6.975-2.305v-.306l-.001-1.934zm-.949 2.24v.016c-.051.422-2.1 1.367-6.025 1.367-3.976 0-6.026-.97-6.026-1.384-.001-.615-.002-1.621 0-2.237 0-.307.008-.67.065-1.031a3.208 3.208 0 01.509-1.293c.055-.081.466-.576 3.434-3.545l.113-.113a6.845 6.845 0 00.24-.262 2.436 2.436 0 00.325-.46c.066-.123.145-.29.175-.494.022-.146.02-.285.018-.408v-.029a1.954 1.954 0 00-.053-.485 1.475 1.475 0 00-.239-.485 4.256 4.256 0 00-.287-.367 8.51 8.51 0 00-.276-.29l-.06-.061c-.05-.052-.187-.189-.378-.38-1.865-1.87-2.878-2.918-3.012-3.117a3.209 3.209 0 01-.509-1.294 6.732 6.732 0 01-.066-1.031V3.168c1.3.643 3.713.981 6.027.981 2.313 0 4.725-.338 6.026-.98v1.143c-.001.308-.01.671-.066 1.031a3.203 3.203 0 01-.51 1.294c-.133.199-1.146 1.247-3.011 3.117-.191.191-.328.328-.378.38l-.064.064c-.09.092-.182.186-.273.287-.109.123-.202.249-.287.367a1.474 1.474 0 00-.239.485 1.95 1.95 0 00-.052.486v.03c-.002.121-.004.26.017.406.03.203.11.37.175.494a2.464 2.464 0 00.325.46 4.399 4.399 0 00.24.261l.157.161.38.382c1.864 1.869 2.877 2.917 3.01 3.115a3.209 3.209 0 01.51 1.294c.057.36.065.723.065 1.031.002.616.001 1.622 0 2.237z"/><path id="Shape" d="M12.715 19.253a5.274 5.274 0 00-.133-.127 5.793 5.793 0 00-.656-.542 5.292 5.292 0 00-.75-.425 11.85 11.85 0 00-1.715-.636c-.145-.042-.29-.084-.435-.128-.154-.048-.31-.09-.457-.155a1.752 1.752 0 01-.325-.185 1.982 1.982 0 01-.447-.45c-.131-.182-.256-.391-.297-.605-.04.214-.166.423-.297.605-.122.17-.27.323-.447.45-.1.073-.21.135-.326.185-.146.064-.303.107-.456.155-.145.044-.29.086-.436.128a11.875 11.875 0 00-1.715.636 5.294 5.294 0 00-.75.425 5.79 5.79 0 00-.655.542 5.297 5.297 0 00-.278.28.858.858 0 00-.14.193C2 20.373 4.461 21 7.497 21c3.035 0 5.496-.627 5.496-1.401H13a.852.852 0 00-.14-.194 5.181 5.181 0 00-.145-.152zM6.417 10.512c.063.06.123.135.177.221.096.153.178.337.244.54.072.219.14.47.162.727.022-.257.09-.508.162-.727.066-.203.148-.387.244-.54.054-.086.114-.16.177-.221.08-.077.166-.129.25-.186.078-.053.158-.103.237-.154.162-.103.321-.214.478-.343.155-.129.309-.266.458-.42.143-.149.28-.316.408-.51.13-.196.245-.42.358-.65a6.916 6.916 0 00.152-.336A1.39 1.39 0 0010 7.681C10 6.753 8.658 6 7.002 6c-1.656 0-2.998.753-2.998 1.681H4c.019.085.046.16.076.232a5.72 5.72 0 00.152.335c.112.231.228.455.357.651.128.194.266.361.41.51a5.4 5.4 0 00.457.42c.156.129.316.24.478.343.08.05.158.1.237.154.084.057.17.109.25.186z"/></g><text id="script-execution-fin" fill="#7E7C7B" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="11" y="129">script execution finished</tspan></text><path id="Line-Copy" fill="#C06334" fill-rule="nonzero" d="M255.5 54.5v59h6l-7 14-7-14h6v-59h2z"/></g></g></svg> No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="430" height="185" viewBox="0 0 430 185"><defs><style>@import url(https://fonts.googleapis.com/css?family=Open+Sans:bold,italic,bolditalic%7CPT+Mono);@font-face{font-family:&apos;PT Mono&apos;;font-weight:700;font-style:normal;src:local(&apos;PT MonoBold&apos;),url(/font/PTMonoBold.woff2) format(&apos;woff2&apos;),url(/font/PTMonoBold.woff) format(&apos;woff&apos;),url(/font/PTMonoBold.ttf) format(&apos;truetype&apos;)}</style></defs><g id="promise" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="promiseQueue.svg"><text id="promise.then(handler" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="12" y="32" fill="#181717">promise</tspan> <tspan x="70.8" y="32" fill="#7E7C7B">.</tspan> <tspan x="79.2" y="32" fill="#181717">then</tspan> <tspan x="112.8" y="32" fill="#7E7C7B">(</tspan> <tspan x="121.2" y="32" fill="#181717">handler</tspan> <tspan x="180" y="32" fill="#7E7C7B">);</tspan> <tspan x="12" y="62" fill="#7E7C7B">...</tspan> <tspan x="12" y="92" fill="#000">alert</tspan> <tspan x="54" y="92" fill="#7E7C7B">(</tspan> <tspan x="50.4" y="92" fill="#478964">&quot;código terminado&quot;</tspan> <tspan x="188.4" y="92" fill="#7E7C7B">);</tspan></text><path id="Line-2" stroke="#7E7C7B" stroke-dasharray="4,4" stroke-linecap="square" d="M4.5 112.5h226"/><text id="handler-enqueued" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="262.5" y="32">tratador enfileirado</tspan></text><text id="queued-handler-runs" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="-15" y="153">tratador enfileirado executa</tspan></text><g id="noun_88566_cc-copy" fill="#7E7C7B" transform="translate(247 16)"><path id="Shape" d="M13.974 19.455c0-.342-.01-.748-.077-1.169a4.11 4.11 0 00-.649-1.653c-.174-.263-1.05-1.176-3.127-3.258a69.969 69.969 0 01-.372-.374l-.156-.159a5.561 5.561 0 01-.2-.217 2.823 2.823 0 01-.056-.07 1.504 1.504 0 01-.157-.226.652.652 0 01-.078-.2 1.729 1.729 0 01-.008-.263v-.031c.002-.106.005-.2.023-.27a.592.592 0 01.098-.186 3.43 3.43 0 01.225-.288c.076-.085.158-.168.244-.256l.065-.067.37-.372c2.078-2.083 2.955-2.997 3.13-3.26a4.106 4.106 0 00.649-1.653 7.57 7.57 0 00.076-1.169V2.261A.741.741 0 0014 2.075C14 .727 10.393 0 7 0S0 .727 0 2.075c0 .062.01.122.025.182v2.057c0 .322.01.745.077 1.17A4.116 4.116 0 00.75 7.135c.174.263 1.051 1.177 3.129 3.26.187.188.32.321.37.373l.062.063a3.43 3.43 0 01.471.547.59.59 0 01.099.186c.018.07.021.16.023.27v.03c.002.096.003.188-.008.263a.647.647 0 01-.078.2 1.515 1.515 0 01-.157.228 2.849 2.849 0 01-.153.177 6.914 6.914 0 01-.103.108l-.104.104c-3.288 3.29-3.486 3.59-3.551 3.688a4.114 4.114 0 00-.649 1.653 7.692 7.692 0 00-.077 1.17v2.239C.025 23.279 3.641 24 7 24c3.36 0 6.975-.721 6.975-2.305v-.306l-.001-1.934zm-.949 2.24v.016c-.051.422-2.1 1.367-6.025 1.367-3.976 0-6.026-.97-6.026-1.384-.001-.615-.002-1.621 0-2.237 0-.307.008-.67.065-1.031a3.208 3.208 0 01.509-1.293c.055-.081.466-.576 3.434-3.545l.113-.113a6.845 6.845 0 00.24-.262 2.436 2.436 0 00.325-.46c.066-.123.145-.29.175-.494.022-.146.02-.285.018-.408v-.029a1.954 1.954 0 00-.053-.485 1.475 1.475 0 00-.239-.485 4.256 4.256 0 00-.287-.367 8.51 8.51 0 00-.276-.29l-.06-.061c-.05-.052-.187-.189-.378-.38-1.865-1.87-2.878-2.918-3.012-3.117a3.209 3.209 0 01-.509-1.294 6.732 6.732 0 01-.066-1.031V3.168c1.3.643 3.713.981 6.027.981 2.313 0 4.725-.338 6.026-.98v1.143c-.001.308-.01.671-.066 1.031a3.203 3.203 0 01-.51 1.294c-.133.199-1.146 1.247-3.011 3.117-.191.191-.328.328-.378.38l-.064.064c-.09.092-.182.186-.273.287-.109.123-.202.249-.287.367a1.474 1.474 0 00-.239.485 1.95 1.95 0 00-.052.486v.03c-.002.121-.004.26.017.406.03.203.11.37.175.494a2.464 2.464 0 00.325.46 4.399 4.399 0 00.24.261l.157.161.38.382c1.864 1.869 2.877 2.917 3.01 3.115a3.209 3.209 0 01.51 1.294c.057.36.065.723.065 1.031.002.616.001 1.622 0 2.237z"/><path id="Shape" d="M12.715 19.253a5.274 5.274 0 00-.133-.127 5.793 5.793 0 00-.656-.542 5.292 5.292 0 00-.75-.425 11.85 11.85 0 00-1.715-.636c-.145-.042-.29-.084-.435-.128-.154-.048-.31-.09-.457-.155a1.752 1.752 0 01-.325-.185 1.982 1.982 0 01-.447-.45c-.131-.182-.256-.391-.297-.605-.04.214-.166.423-.297.605-.122.17-.27.323-.447.45-.1.073-.21.135-.326.185-.146.064-.303.107-.456.155-.145.044-.29.086-.436.128a11.875 11.875 0 00-1.715.636 5.294 5.294 0 00-.75.425 5.79 5.79 0 00-.655.542 5.297 5.297 0 00-.278.28.858.858 0 00-.14.193C2 20.373 4.461 21 7.497 21c3.035 0 5.496-.627 5.496-1.401H13a.852.852 0 00-.14-.194 5.181 5.181 0 00-.145-.152zM6.417 10.512c.063.06.123.135.177.221.096.153.178.337.244.54.072.219.14.47.162.727.022-.257.09-.508.162-.727.066-.203.148-.387.244-.54.054-.086.114-.16.177-.221.08-.077.166-.129.25-.186.078-.053.158-.103.237-.154.162-.103.321-.214.478-.343.155-.129.309-.266.458-.42.143-.149.28-.316.408-.51.13-.196.245-.42.358-.65a6.916 6.916 0 00.152-.336A1.39 1.39 0 0010 7.681C10 6.753 8.658 6 7.002 6c-1.656 0-2.998.753-2.998 1.681H4c.019.085.046.16.076.232a5.72 5.72 0 00.152.335c.112.231.228.455.357.651.128.194.266.361.41.51a5.4 5.4 0 00.457.42c.156.129.316.24.478.343.08.05.158.1.237.154.084.057.17.109.25.186z"/></g><text id="script-execution-fin" fill="#7E7C7B" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="-0.5" y="129">execução do script terminada</tspan></text><path id="Line-Copy" fill="#C06334" fill-rule="nonzero" d="M255.5 54.5v59h6l-7 14-7-14h6v-59h2z"/></g></g></svg> No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The "código terminado" tspan was moved to x=50.4, but alert ends at x=54 and ( sits at x=54–62.4. The new string is 18 monospace chars × 8.4px ≈ 151px wide, so it ends at about 201.6, while ); is still at x=188.4. So in the rendered diagram the opening quote sits on top of t(, and o" sits on top of );, and the code line reads as garbled text. Fix: keep the string at x=62.4, move ); to about x=213.6, and lengthen the dashed Line-2 path to match.

@@ -1 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" width="430" height="185" viewBox="0 0 430 185"><defs><style>@import url(https://fonts.googleapis.com/css?family=Open+Sans:bold,italic,bolditalic%7CPT+Mono);@font-face{font-family:&apos;PT Mono&apos;;font-weight:700;font-style:normal;src:local(&apos;PT MonoBold&apos;),url(/font/PTMonoBold.woff2) format(&apos;woff2&apos;),url(/font/PTMonoBold.woff) format(&apos;woff&apos;),url(/font/PTMonoBold.ttf) format(&apos;truetype&apos;)}</style></defs><g id="promise" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="promiseQueue.svg"><text id="promise.then(handler" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="12" y="32" fill="#181717">promise</tspan> <tspan x="70.8" y="32" fill="#7E7C7B">.</tspan> <tspan x="79.2" y="32" fill="#181717">then</tspan> <tspan x="112.8" y="32" fill="#7E7C7B">(</tspan> <tspan x="121.2" y="32" fill="#181717">handler</tspan> <tspan x="180" y="32" fill="#7E7C7B">);</tspan> <tspan x="12" y="62" fill="#7E7C7B">...</tspan> <tspan x="12" y="92" fill="#000">alert</tspan> <tspan x="54" y="92" fill="#7E7C7B">(</tspan> <tspan x="62.4" y="92" fill="#478964">&quot;code finished&quot;</tspan> <tspan x="188.4" y="92" fill="#7E7C7B">);</tspan></text><path id="Line-2" stroke="#7E7C7B" stroke-dasharray="4,4" stroke-linecap="square" d="M4.5 112.5h226"/><text id="handler-enqueued" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="267" y="32">handler enqueued</tspan></text><text id="queued-handler-runs" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="11" y="153">queued handler runs</tspan></text><g id="noun_88566_cc-copy" fill="#7E7C7B" transform="translate(247 16)"><path id="Shape" d="M13.974 19.455c0-.342-.01-.748-.077-1.169a4.11 4.11 0 00-.649-1.653c-.174-.263-1.05-1.176-3.127-3.258a69.969 69.969 0 01-.372-.374l-.156-.159a5.561 5.561 0 01-.2-.217 2.823 2.823 0 01-.056-.07 1.504 1.504 0 01-.157-.226.652.652 0 01-.078-.2 1.729 1.729 0 01-.008-.263v-.031c.002-.106.005-.2.023-.27a.592.592 0 01.098-.186 3.43 3.43 0 01.225-.288c.076-.085.158-.168.244-.256l.065-.067.37-.372c2.078-2.083 2.955-2.997 3.13-3.26a4.106 4.106 0 00.649-1.653 7.57 7.57 0 00.076-1.169V2.261A.741.741 0 0014 2.075C14 .727 10.393 0 7 0S0 .727 0 2.075c0 .062.01.122.025.182v2.057c0 .322.01.745.077 1.17A4.116 4.116 0 00.75 7.135c.174.263 1.051 1.177 3.129 3.26.187.188.32.321.37.373l.062.063a3.43 3.43 0 01.471.547.59.59 0 01.099.186c.018.07.021.16.023.27v.03c.002.096.003.188-.008.263a.647.647 0 01-.078.2 1.515 1.515 0 01-.157.228 2.849 2.849 0 01-.153.177 6.914 6.914 0 01-.103.108l-.104.104c-3.288 3.29-3.486 3.59-3.551 3.688a4.114 4.114 0 00-.649 1.653 7.692 7.692 0 00-.077 1.17v2.239C.025 23.279 3.641 24 7 24c3.36 0 6.975-.721 6.975-2.305v-.306l-.001-1.934zm-.949 2.24v.016c-.051.422-2.1 1.367-6.025 1.367-3.976 0-6.026-.97-6.026-1.384-.001-.615-.002-1.621 0-2.237 0-.307.008-.67.065-1.031a3.208 3.208 0 01.509-1.293c.055-.081.466-.576 3.434-3.545l.113-.113a6.845 6.845 0 00.24-.262 2.436 2.436 0 00.325-.46c.066-.123.145-.29.175-.494.022-.146.02-.285.018-.408v-.029a1.954 1.954 0 00-.053-.485 1.475 1.475 0 00-.239-.485 4.256 4.256 0 00-.287-.367 8.51 8.51 0 00-.276-.29l-.06-.061c-.05-.052-.187-.189-.378-.38-1.865-1.87-2.878-2.918-3.012-3.117a3.209 3.209 0 01-.509-1.294 6.732 6.732 0 01-.066-1.031V3.168c1.3.643 3.713.981 6.027.981 2.313 0 4.725-.338 6.026-.98v1.143c-.001.308-.01.671-.066 1.031a3.203 3.203 0 01-.51 1.294c-.133.199-1.146 1.247-3.011 3.117-.191.191-.328.328-.378.38l-.064.064c-.09.092-.182.186-.273.287-.109.123-.202.249-.287.367a1.474 1.474 0 00-.239.485 1.95 1.95 0 00-.052.486v.03c-.002.121-.004.26.017.406.03.203.11.37.175.494a2.464 2.464 0 00.325.46 4.399 4.399 0 00.24.261l.157.161.38.382c1.864 1.869 2.877 2.917 3.01 3.115a3.209 3.209 0 01.51 1.294c.057.36.065.723.065 1.031.002.616.001 1.622 0 2.237z"/><path id="Shape" d="M12.715 19.253a5.274 5.274 0 00-.133-.127 5.793 5.793 0 00-.656-.542 5.292 5.292 0 00-.75-.425 11.85 11.85 0 00-1.715-.636c-.145-.042-.29-.084-.435-.128-.154-.048-.31-.09-.457-.155a1.752 1.752 0 01-.325-.185 1.982 1.982 0 01-.447-.45c-.131-.182-.256-.391-.297-.605-.04.214-.166.423-.297.605-.122.17-.27.323-.447.45-.1.073-.21.135-.326.185-.146.064-.303.107-.456.155-.145.044-.29.086-.436.128a11.875 11.875 0 00-1.715.636 5.294 5.294 0 00-.75.425 5.79 5.79 0 00-.655.542 5.297 5.297 0 00-.278.28.858.858 0 00-.14.193C2 20.373 4.461 21 7.497 21c3.035 0 5.496-.627 5.496-1.401H13a.852.852 0 00-.14-.194 5.181 5.181 0 00-.145-.152zM6.417 10.512c.063.06.123.135.177.221.096.153.178.337.244.54.072.219.14.47.162.727.022-.257.09-.508.162-.727.066-.203.148-.387.244-.54.054-.086.114-.16.177-.221.08-.077.166-.129.25-.186.078-.053.158-.103.237-.154.162-.103.321-.214.478-.343.155-.129.309-.266.458-.42.143-.149.28-.316.408-.51.13-.196.245-.42.358-.65a6.916 6.916 0 00.152-.336A1.39 1.39 0 0010 7.681C10 6.753 8.658 6 7.002 6c-1.656 0-2.998.753-2.998 1.681H4c.019.085.046.16.076.232a5.72 5.72 0 00.152.335c.112.231.228.455.357.651.128.194.266.361.41.51a5.4 5.4 0 00.457.42c.156.129.316.24.478.343.08.05.158.1.237.154.084.057.17.109.25.186z"/></g><text id="script-execution-fin" fill="#7E7C7B" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="11" y="129">script execution finished</tspan></text><path id="Line-Copy" fill="#C06334" fill-rule="nonzero" d="M255.5 54.5v59h6l-7 14-7-14h6v-59h2z"/></g></g></svg> No newline at end of file
<svg xmlns="http://www.w3.org/2000/svg" width="430" height="185" viewBox="0 0 430 185"><defs><style>@import url(https://fonts.googleapis.com/css?family=Open+Sans:bold,italic,bolditalic%7CPT+Mono);@font-face{font-family:&apos;PT Mono&apos;;font-weight:700;font-style:normal;src:local(&apos;PT MonoBold&apos;),url(/font/PTMonoBold.woff2) format(&apos;woff2&apos;),url(/font/PTMonoBold.woff) format(&apos;woff&apos;),url(/font/PTMonoBold.ttf) format(&apos;truetype&apos;)}</style></defs><g id="promise" fill="none" fill-rule="evenodd" stroke="none" stroke-width="1"><g id="promiseQueue.svg"><text id="promise.then(handler" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="12" y="32" fill="#181717">promise</tspan> <tspan x="70.8" y="32" fill="#7E7C7B">.</tspan> <tspan x="79.2" y="32" fill="#181717">then</tspan> <tspan x="112.8" y="32" fill="#7E7C7B">(</tspan> <tspan x="121.2" y="32" fill="#181717">handler</tspan> <tspan x="180" y="32" fill="#7E7C7B">);</tspan> <tspan x="12" y="62" fill="#7E7C7B">...</tspan> <tspan x="12" y="92" fill="#000">alert</tspan> <tspan x="54" y="92" fill="#7E7C7B">(</tspan> <tspan x="50.4" y="92" fill="#478964">&quot;código terminado&quot;</tspan> <tspan x="188.4" y="92" fill="#7E7C7B">);</tspan></text><path id="Line-2" stroke="#7E7C7B" stroke-dasharray="4,4" stroke-linecap="square" d="M4.5 112.5h226"/><text id="handler-enqueued" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="262.5" y="32">tratador enfileirado</tspan></text><text id="queued-handler-runs" fill="#AF6E24" font-family="OpenSans-Regular, Open Sans" font-size="16" font-weight="normal"><tspan x="-15" y="153">tratador enfileirado executa</tspan></text><g id="noun_88566_cc-copy" fill="#7E7C7B" transform="translate(247 16)"><path id="Shape" d="M13.974 19.455c0-.342-.01-.748-.077-1.169a4.11 4.11 0 00-.649-1.653c-.174-.263-1.05-1.176-3.127-3.258a69.969 69.969 0 01-.372-.374l-.156-.159a5.561 5.561 0 01-.2-.217 2.823 2.823 0 01-.056-.07 1.504 1.504 0 01-.157-.226.652.652 0 01-.078-.2 1.729 1.729 0 01-.008-.263v-.031c.002-.106.005-.2.023-.27a.592.592 0 01.098-.186 3.43 3.43 0 01.225-.288c.076-.085.158-.168.244-.256l.065-.067.37-.372c2.078-2.083 2.955-2.997 3.13-3.26a4.106 4.106 0 00.649-1.653 7.57 7.57 0 00.076-1.169V2.261A.741.741 0 0014 2.075C14 .727 10.393 0 7 0S0 .727 0 2.075c0 .062.01.122.025.182v2.057c0 .322.01.745.077 1.17A4.116 4.116 0 00.75 7.135c.174.263 1.051 1.177 3.129 3.26.187.188.32.321.37.373l.062.063a3.43 3.43 0 01.471.547.59.59 0 01.099.186c.018.07.021.16.023.27v.03c.002.096.003.188-.008.263a.647.647 0 01-.078.2 1.515 1.515 0 01-.157.228 2.849 2.849 0 01-.153.177 6.914 6.914 0 01-.103.108l-.104.104c-3.288 3.29-3.486 3.59-3.551 3.688a4.114 4.114 0 00-.649 1.653 7.692 7.692 0 00-.077 1.17v2.239C.025 23.279 3.641 24 7 24c3.36 0 6.975-.721 6.975-2.305v-.306l-.001-1.934zm-.949 2.24v.016c-.051.422-2.1 1.367-6.025 1.367-3.976 0-6.026-.97-6.026-1.384-.001-.615-.002-1.621 0-2.237 0-.307.008-.67.065-1.031a3.208 3.208 0 01.509-1.293c.055-.081.466-.576 3.434-3.545l.113-.113a6.845 6.845 0 00.24-.262 2.436 2.436 0 00.325-.46c.066-.123.145-.29.175-.494.022-.146.02-.285.018-.408v-.029a1.954 1.954 0 00-.053-.485 1.475 1.475 0 00-.239-.485 4.256 4.256 0 00-.287-.367 8.51 8.51 0 00-.276-.29l-.06-.061c-.05-.052-.187-.189-.378-.38-1.865-1.87-2.878-2.918-3.012-3.117a3.209 3.209 0 01-.509-1.294 6.732 6.732 0 01-.066-1.031V3.168c1.3.643 3.713.981 6.027.981 2.313 0 4.725-.338 6.026-.98v1.143c-.001.308-.01.671-.066 1.031a3.203 3.203 0 01-.51 1.294c-.133.199-1.146 1.247-3.011 3.117-.191.191-.328.328-.378.38l-.064.064c-.09.092-.182.186-.273.287-.109.123-.202.249-.287.367a1.474 1.474 0 00-.239.485 1.95 1.95 0 00-.052.486v.03c-.002.121-.004.26.017.406.03.203.11.37.175.494a2.464 2.464 0 00.325.46 4.399 4.399 0 00.24.261l.157.161.38.382c1.864 1.869 2.877 2.917 3.01 3.115a3.209 3.209 0 01.51 1.294c.057.36.065.723.065 1.031.002.616.001 1.622 0 2.237z"/><path id="Shape" d="M12.715 19.253a5.274 5.274 0 00-.133-.127 5.793 5.793 0 00-.656-.542 5.292 5.292 0 00-.75-.425 11.85 11.85 0 00-1.715-.636c-.145-.042-.29-.084-.435-.128-.154-.048-.31-.09-.457-.155a1.752 1.752 0 01-.325-.185 1.982 1.982 0 01-.447-.45c-.131-.182-.256-.391-.297-.605-.04.214-.166.423-.297.605-.122.17-.27.323-.447.45-.1.073-.21.135-.326.185-.146.064-.303.107-.456.155-.145.044-.29.086-.436.128a11.875 11.875 0 00-1.715.636 5.294 5.294 0 00-.75.425 5.79 5.79 0 00-.655.542 5.297 5.297 0 00-.278.28.858.858 0 00-.14.193C2 20.373 4.461 21 7.497 21c3.035 0 5.496-.627 5.496-1.401H13a.852.852 0 00-.14-.194 5.181 5.181 0 00-.145-.152zM6.417 10.512c.063.06.123.135.177.221.096.153.178.337.244.54.072.219.14.47.162.727.022-.257.09-.508.162-.727.066-.203.148-.387.244-.54.054-.086.114-.16.177-.221.08-.077.166-.129.25-.186.078-.053.158-.103.237-.154.162-.103.321-.214.478-.343.155-.129.309-.266.458-.42.143-.149.28-.316.408-.51.13-.196.245-.42.358-.65a6.916 6.916 0 00.152-.336A1.39 1.39 0 0010 7.681C10 6.753 8.658 6 7.002 6c-1.656 0-2.998.753-2.998 1.681H4c.019.085.046.16.076.232a5.72 5.72 0 00.152.335c.112.231.228.455.357.651.128.194.266.361.41.51a5.4 5.4 0 00.457.42c.156.129.316.24.478.343.08.05.158.1.237.154.084.057.17.109.25.186z"/></g><text id="script-execution-fin" fill="#7E7C7B" font-family="PTMono-Regular, PT Mono" font-size="14" font-weight="normal"><tspan x="-0.5" y="129">execução do script terminada</tspan></text><path id="Line-Copy" fill="#C06334" fill-rule="nonzero" d="M255.5 54.5v59h6l-7 14-7-14h6v-59h2z"/></g></g></svg> No newline at end of file

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

<tspan x="-15" y="153">tratador enfileirado executa</tspan> starts 15px to the left of the viewBox (0 0 430 185), so the first letters ("tr…") are cut off when the image is shown. execução do script terminada at x=-0.5 also starts outside the canvas, and at 28 × 8.4 ≈ 235px it runs past the dashed separator, which ends at x≈230. Left-align both labels at x≈11 as in the original, and widen the line or canvas if needed.

Comment thread images.yml Outdated
position: center
"queued handler runs":
text: "tratador enfileirado executa"
position: center

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the original SVG, queued handler runs and script execution finished are left-aligned at x=11, and handler enqueued starts right after the hourglass icon (x=247–261). With position: center, the translation tool centers each longer Portuguese string on the original string's center. That pushes the two bottom labels to negative x, where they get clipped (the same thing the hand edit produced with x=-15), and pushes tratador enfileirado left onto the icon. Use position: left for these three entries. ifelse_task2.svg already uses left for "You don't know?".

Comment thread images.yml
"I love":
"text": "Eu amo"
"position": "center"
promiseQueue.svg:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR both hand-edits promiseQueue.svg and adds images.yml entries for it. After the hand edit, the SVG no longer contains "code finished", handler enqueued, queued handler runs or script execution finished, so none of these entries match the file in this repo. On the next upstream sync, the hand-edited SVG will also conflict with the English source. Other SVGs listed in images.yml (ifelse_task.svg, proto-constructor-animal-rabbit.svg) keep their English text and get their translations only from images.yml. Suggest reverting the SVG change and relying on images.yml alone.

Se não soubéssemos sobre a fila de microtasks, poderíamos nos perguntar: "Por que o tratador de `unhandledrejection` rodou? Nós capturamos e tratamos o erro!"

But now we understand that `unhandledrejection` is generated when the microtask queue is complete: the engine examines promises and, if any of them is in the "rejected" state, then the event triggers.
Mas agora entendemos que o `unhandledrejection` é gerado quando a fila de microtasks está completa: o motor examina as promessas e, se qualquer uma delas estiver no estado "rejected", o evento dispara.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"quando a fila de microtasks está completa" changes the meaning. In the original, "the queue is complete" means it has been fully processed, so it is empty. In Portuguese, "a fila está completa" reads as "the queue is full", which is the opposite. Suggest "quando a fila de microtasks termina de ser processada" or "quando a fila de microtasks fica vazia", to match line 75.

Se precisarmos garantir que um trecho de código seja executado depois de `.then/catch/finally`, podemos adicioná-lo em uma chamada `.then` encadeada.

In most Javascript engines, including browsers and Node.js, the concept of microtasks is closely tied with the "event loop" and "macrotasks". As these have no direct relation to promises, they are covered in another part of the tutorial, in the article <info:event-loop>.
Na maioria dos motores JavaScript, incluindo navegadores e Node.js, o conceito de microtasks está intimamente ligado ao "event loop" e às "macrotasks". Como eles não têm relação direta com promessas, são cobertos em outra parte do tutorial, no artigo <info:event-loop>.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLAUDE.md says: "avoid using foreign words: Words like timer, loop, inline should be avoided." This line keeps "event loop" and "macrotasks" in English. Suggest "loop de eventos" or "ciclo de eventos", and "macrotarefas".


Why did the `.then` trigger afterwards? What's going on?
Por que o `.then` disparou depois? O que está acontecendo?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

CLAUDE.md says: "avoid using foreign words: Words like timer, loop, inline should be avoided." The heading ## Fila de microtasks and every later "fila de microtasks" keep the English word. The page title # Microtasks on line 1 was also left untranslated. Consider "microtarefas" ("fila de microtarefas"), keeping "microtask" once in parentheses as the V8 term.

Comment thread images.yml Outdated
text: "tratador enfileirado"
position: center
"queued handler runs":
text: "tratador enfileirado executa"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"tratador enfileirado executa" uses executar without an object, so it reads as "the queued handler executes [something]". The original means "the queued handler is run". Suggest "tratador enfileirado é executado" or "o tratador enfileirado roda". The same text appears in promiseQueue.svg.

@diogoosz

diogoosz commented Nov 8, 2026

Copy link
Copy Markdown
Contributor Author

Obrigado pela análise detalhada, @gabifs! Revertei o SVG editado à mão (mantendo só o images.yml como fonte, como o CLAUDE.md pede), ajustei o position de 3 entradas pra left e corrigi o texto "é executado". Também corrigi "microtasks"→"microtarefas", "event loop"→"loop de eventos", "macrotasks"→"macrotarefas" em todo o artigo (mantendo microtask queue uma vez entre parênteses como termo do V8), e corrigi o sentido de "fila completa" pra "termina de ser processada".

@gabifs
gabifs merged commit 253830a into javascript-tutorial:master Nov 8, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants