<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq" -->

---
title: Fixing Top-Level Await in Safari | daily.dev
description: Safari 27&#x27;s WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused &#x27;accessed before...
canonical: https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Fixing Top-Level Await in Safari | daily.dev
og:description: Safari 27&#x27;s WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused &#x27;accessed before...
og:url: https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq
og:image: https://api.daily.dev/og/posts/kCSPlB3AQ.png
og:image:alt: Fixing Top-Level Await in Safari
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Fixing Top-Level Await in Safari

**[WebKit](https://daily.dev/sources/webkit)** · 8 min read · 14 upvotes · 3 comments

## Summary

Safari 27's WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused 'accessed before initialization' errors and incorrect module evaluation ordering. The team rewrote Safari's module loader from scratch in native C++, replacing an outdated implementation based on the abandoned WHATWG Loader proposal. The rewrite was validated using fuzzing, test262, WPT tests, and test cases contributed by Bun engineers, and is available now in Safari Technology Preview 251 and the Safari 27 beta.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://webkit.org/blog/18227/fixing-top-level-await-in-safari>

## Questions this post answers

### Does Safari 27 fully support top-level await in JavaScript modules?

Yes, Safari 27 (and Safari Technology Preview 251) fixes top-level await by rewriting the module loader from scratch in native C++, replacing the old implementation based on the abandoned WHATWG Loader proposal. Previously, developers could hit 'accessed before initialization' errors and incorrect module evaluation ordering when using top-level await; these are now resolved.

_Track this kind of browser-engine fix on daily.dev before relying on top-level await in production._

### Why did top-level await cause 'Cannot access before initialization' errors in old versions of Safari?

Safari's module loader was built on the WHATWG Loader proposal, which predates async/await in ECMAScript and was abandoned before top-level await existed. This mismatch caused the loader to resolve import promises before the awaited module finished evaluating, so code sometimes accessed module exports before they were initialized, producing this specific error and out-of-order import completion.

_Developers debugging module-loading quirks can follow root-cause writeups like this on daily.dev._

### How was Safari's new JavaScript module loader tested before release?

The rewritten module loader was validated using a custom fuzzer that generated complex module dependency graphs and compared output byte-for-byte against other JavaScript engines, plus full test262 and Web Platform Tests (WPT) module test suites with no regressions. Bun engineers, whose runtime shares JavaScriptCore, also contributed real-world test cases that had exposed the old loader's bugs.

_Engineers evaluating engine-level changes can follow this kind of testing detail on daily.dev._

## Community discussion

Top comments from developers on daily.dev.

**@allinonetools** · 4 upvotes

> Nice to see Safari finally getting this right. Module loading bugs can be incredibly frustrating because everything looks fine until a specific browser breaks it.

**@agustinbarrientos** · 0 upvotes

> I think the regression suite should keep one minimized graph per distinct failure mode. Static and repeated dynamic imports can stay separate. When engines disagree, the fuzzer shouldn't silently assume one implementation is correct.

## Similar posts on daily.dev

- [News from WWDC26: WebKit in Safari 27 beta](https://daily.dev/posts/news-from-wwdc26-webkit-in-safari-27-beta-cz81svuy5) · WebKit · 12 upvotes · 1 comments
- [Release Notes for Safari Technology Preview 238](https://daily.dev/posts/release-notes-for-safari-technology-preview-238-nui8ncsfj) · WebKit · 0 upvotes · 0 comments
- [Release Notes for Safari Technology Preview 244](https://daily.dev/posts/release-notes-for-safari-technology-preview-244-aqbh7pydl) · WebKit · 10 upvotes · 1 comments

---

Tags: [#javascript](https://daily.dev/tags/javascript), [#safari](https://daily.dev/tags/safari)

[View this post on daily.dev](https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Fixing Top-Level Await in Safari","url":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq"},"datePublished":"2026-09-02T17:10:10.634Z","dateModified":"2026-09-02T17:34:05.503Z","description":"Safari 27's WebKit engine now fully complies with the ECMAScript spec for top-level await, fixing longstanding bugs that caused 'accessed before...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d50208ab2c6648366673f4377de21c6f?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/d50208ab2c6648366673f4377de21c6f?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"WebKit","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"WebKit","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/webkit","url":"https://daily.dev/sources/webkit"},"commentCount":3,"discussionUrl":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":14},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":3}],"keywords":"javascript,safari","timeRequired":"PT8M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"WebKit","item":"https://daily.dev/sources/webkit"},{"@type":"ListItem","position":3,"name":"Fixing Top-Level Await in Safari"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq","comment":[{"@type":"Comment","text":"Nice to see Safari finally getting this right. Module loading bugs can be incredibly frustrating because everything looks fine until a specific browser breaks it.","datePublished":"2026-09-03T03:22:10.418Z","url":"https://daily.dev/posts/kCSPlB3AQ#c-S1pBBzNDl","author":{"@type":"Person","name":"AllInOneTools","url":"https://daily.dev/allinonetools","image":"https://media.daily.dev/image/upload/s--4ZT8QlF0--/f_auto/v1769790028/avatars/avatar_igzBsWloJeaegzm9bQltZ?_a=BAMAMiiu0"},"interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":4}},{"@type":"Comment","text":"I think the regression suite should keep one minimized graph per distinct failure mode. Static and repeated dynamic imports can stay separate. When engines disagree, the fuzzer shouldn’t silently assume one implementation is correct.","datePublished":"2026-09-04T18:29:34.632Z","url":"https://daily.dev/posts/kCSPlB3AQ#c-g2TeYpfiL","author":{"@type":"Person","name":"Agustin Barrientos","url":"https://daily.dev/agustinbarrientos","image":"https://media.daily.dev/image/upload/s--5ayxQnqn--/f_auto/v1788281802/avatars/avatar_wQYYVe5Tbj0NJ7C7qPoa8?_a=BAMAMicg0"}}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/fixing-top-level-await-in-safari-kcsplb3aq#faq","mainEntity":[{"@type":"Question","name":"Does Safari 27 fully support top-level await in JavaScript modules?","acceptedAnswer":{"@type":"Answer","text":"Yes, Safari 27 (and Safari Technology Preview 251) fixes top-level await by rewriting the module loader from scratch in native C++, replacing the old implementation based on the abandoned WHATWG Loader proposal. Previously, developers could hit 'accessed before initialization' errors and incorrect module evaluation ordering when using top-level await; these are now resolved. Track this kind of browser-engine fix on daily.dev before relying on top-level await in production."}},{"@type":"Question","name":"Why did top-level await cause 'Cannot access before initialization' errors in old versions of Safari?","acceptedAnswer":{"@type":"Answer","text":"Safari's module loader was built on the WHATWG Loader proposal, which predates async/await in ECMAScript and was abandoned before top-level await existed. This mismatch caused the loader to resolve import promises before the awaited module finished evaluating, so code sometimes accessed module exports before they were initialized, producing this specific error and out-of-order import completion. Developers debugging module-loading quirks can follow root-cause writeups like this on daily.dev."}},{"@type":"Question","name":"How was Safari's new JavaScript module loader tested before release?","acceptedAnswer":{"@type":"Answer","text":"The rewritten module loader was validated using a custom fuzzer that generated complex module dependency graphs and compared output byte-for-byte against other JavaScript engines, plus full test262 and Web Platform Tests (WPT) module test suites with no regressions. Bun engineers, whose runtime shares JavaScriptCore, also contributed real-world test cases that had exposed the old loader's bugs. Engineers evaluating engine-level changes can follow this kind of testing detail on daily.dev."}}]}
```

