Buffer concurrent requests (#51)

* Buffer concurrent requests

* comment
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 932dc54..cd0dd52 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,8 @@
+## 4.1.0
+
+- Limit the number of concurrent requests to prevent Chrome from automatically
+  dropping them on the floor.
+
 ## 4.0.0
 
 - Support null safety.
diff --git a/lib/client/sse_client.dart b/lib/client/sse_client.dart
index 0f1da87..3335346 100644
--- a/lib/client/sse_client.dart
+++ b/lib/client/sse_client.dart
@@ -7,10 +7,19 @@
 import 'dart:html';
 
 import 'package:logging/logging.dart';
+import 'package:pool/pool.dart';
 import 'package:stream_channel/stream_channel.dart';
 
 import '../src/util/uuid.dart';
 
+/// Limit for the number of concurrent outgoing requests.
+///
+/// Chrome drops outgoing requests on the floor after some threshold. To prevent
+/// these errors we buffer outgoing requests with a pool.
+///
+/// Note Chrome's limit is 6000. So this gives us plenty of headroom.
+final _requestPool = Pool(1000);
+
 /// A client for bi-directional sse communcation.
 ///
 /// The client can send any JSON-encodable messages to the server by adding
@@ -115,19 +124,21 @@
 
   void _onOutgoingMessage(String? message) async {
     String? encodedMessage;
-    try {
-      encodedMessage = jsonEncode(message);
-    } on JsonUnsupportedObjectError catch (e) {
-      _logger.warning('Unable to encode outgoing message: $e');
-    } on ArgumentError catch (e) {
-      _logger.warning('Invalid argument: $e');
-    }
-    try {
-      await HttpRequest.request('$_serverUrl&messageId=${++_lastMessageId}',
-          method: 'POST', sendData: encodedMessage, withCredentials: true);
-    } catch (e) {
-      _logger.severe('Failed to send $message:\n $e');
-      close();
-    }
+    await _requestPool.withResource(() async {
+      try {
+        encodedMessage = jsonEncode(message);
+      } on JsonUnsupportedObjectError catch (e) {
+        _logger.warning('Unable to encode outgoing message: $e');
+      } on ArgumentError catch (e) {
+        _logger.warning('Invalid argument: $e');
+      }
+      try {
+        await HttpRequest.request('$_serverUrl&messageId=${++_lastMessageId}',
+            method: 'POST', sendData: encodedMessage, withCredentials: true);
+      } catch (e) {
+        _logger.severe('Failed to send $message:\n $e');
+        close();
+      }
+    });
   }
 }
diff --git a/pubspec.yaml b/pubspec.yaml
index 6f637fe..1c2b351 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
 name: sse
-version: 4.0.0
+version: 4.1.0
 homepage: https://github.com/dart-lang/sse
 description: >-
   Provides client and server functionality for setting up bi-directional
@@ -13,6 +13,7 @@
   async: ^2.0.8
   collection: ^1.0.0
   logging: '>=0.11.3+2 <2.0.0'
+  pool: ^1.5.0
   pedantic: ^1.4.0
   stream_channel: '>=1.6.8 <3.0.0'
   shelf: ^1.1.0
diff --git a/test/sse_test.dart b/test/sse_test.dart
index ad84d7e..5fc898c 100644
--- a/test/sse_test.dart
+++ b/test/sse_test.dart
@@ -67,6 +67,16 @@
       expect(await connection.stream.first, 'blah');
     });
 
+    test('can send a significant number of requests', () async {
+      await webdriver.get('http://localhost:${server.port}');
+      var connection = await handler.connections.next;
+      var limit = 7000;
+      for (var i = 0; i < limit; i++) {
+        connection.sink.add('$i');
+      }
+      await connection.stream.take(limit).toList();
+    });
+
     test('messages arrive in-order', () async {
       expect(handler.numberOfClients, 0);
       await webdriver.get('http://localhost:${server.port}');
diff --git a/test/web/index.dart.js b/test/web/index.dart.js
index 741866a..d3554da 100644
--- a/test/web/index.dart.js
+++ b/test/web/index.dart.js
@@ -1,4 +1,4 @@
-// Generated by dart2js (fast startup emitter, strong), the Dart to JavaScript compiler version: 2.13.0-203.0.dev.
+// Generated by dart2js (fast startup emitter, strong), the Dart to JavaScript compiler version: 2.13.0.
 // The code supports the following hooks:
 // dartPrint(message):
 //    if this function is defined it is called instead of the Dart [print]
@@ -265,6 +265,9 @@
     IterableElementError_noElement: function() {
       return new P.StateError("No element");
     },
+    IterableElementError_tooFew: function() {
+      return new P.StateError("Too few elements");
+    },
     LateError: function LateError(t0) {
       this._message = t0;
     },
@@ -324,18 +327,32 @@
       return hash;
     },
     Primitives_parseInt: function(source, radix) {
-      var decimalMatch,
+      var decimalMatch, maxCharCode, digitsPart, t1, i, _null = null,
         match = /^\s*[+-]?((0x[a-f0-9]+)|(\d+)|([a-z0-9]+))\s*$/i.exec(source);
       if (match == null)
-        return null;
+        return _null;
       if (3 >= match.length)
         return H.ioore(match, 3);
       decimalMatch = match[3];
-      if (decimalMatch != null)
+      if (radix == null) {
+        if (decimalMatch != null)
+          return parseInt(source, 10);
+        if (match[2] != null)
+          return parseInt(source, 16);
+        return _null;
+      }
+      if (radix < 2 || radix > 36)
+        throw H.wrapException(P.RangeError$range(radix, 2, 36, "radix", _null));
+      if (radix === 10 && decimalMatch != null)
         return parseInt(source, 10);
-      if (match[2] != null)
-        return parseInt(source, 16);
-      return null;
+      if (radix < 10 || decimalMatch == null) {
+        maxCharCode = radix <= 10 ? 47 + radix : 86 + radix;
+        digitsPart = match[1];
+        for (t1 = digitsPart.length, i = 0; i < t1; ++i)
+          if ((C.JSString_methods._codeUnitAt$1(digitsPart, i) | 32) > maxCharCode)
+            return _null;
+      }
+      return parseInt(source, radix);
     },
     Primitives_objectTypeName: function(object) {
       return H.Primitives__objectTypeNameNewRti(object);
@@ -364,11 +381,13 @@
     },
     Primitives_stringFromCharCode: function(charCode) {
       var bits;
-      if (charCode <= 65535)
-        return String.fromCharCode(charCode);
-      if (charCode <= 1114111) {
-        bits = charCode - 65536;
-        return String.fromCharCode((C.JSInt_methods._shrOtherPositive$1(bits, 10) | 55296) >>> 0, bits & 1023 | 56320);
+      if (0 <= charCode) {
+        if (charCode <= 65535)
+          return String.fromCharCode(charCode);
+        if (charCode <= 1114111) {
+          bits = charCode - 65536;
+          return String.fromCharCode((C.JSInt_methods._shrOtherPositive$1(bits, 10) | 55296) >>> 0, bits & 1023 | 56320);
+        }
       }
       throw H.wrapException(P.RangeError$range(charCode, 0, 1114111, null, null));
     },
@@ -1134,6 +1153,10 @@
     initHooks_closure1: function initHooks_closure1(t0) {
       this.prototypeForTag = t0;
     },
+    StringMatch: function StringMatch(t0, t1) {
+      this.start = t0;
+      this.pattern = t1;
+    },
     _checkValidIndex: function(index, list, $length) {
       if (index >>> 0 !== index || index >= $length)
         throw H.wrapException(H.diagnoseIndexError(list, index));
@@ -2646,6 +2669,19 @@
       }
       return C.UnknownJavaScriptObject_methods;
     },
+    JSArray_JSArray$fixed: function($length, $E) {
+      if ($length < 0 || $length > 4294967295)
+        throw H.wrapException(P.RangeError$range($length, 0, 4294967295, "length", null));
+      return J.JSArray_JSArray$markFixed(new Array($length), $E);
+    },
+    JSArray_JSArray$growable: function($length, $E) {
+      if ($length < 0)
+        throw H.wrapException(P.ArgumentError$("Length must be a non-negative integer: " + $length));
+      return H.setRuntimeTypeInfo(new Array($length), $E._eval$1("JSArray<0>"));
+    },
+    JSArray_JSArray$markFixed: function(allocation, $E) {
+      return J.JSArray_markFixedList(H.setRuntimeTypeInfo(allocation, $E._eval$1("JSArray<0>")), $E);
+    },
     JSArray_markFixedList: function(list, $T) {
       list.fixed$length = Array;
       return list;
@@ -2703,6 +2739,15 @@
         return receiver;
       return J.getNativeInterceptor(receiver);
     },
+    getInterceptor$s: function(receiver) {
+      if (typeof receiver == "string")
+        return J.JSString.prototype;
+      if (receiver == null)
+        return receiver;
+      if (!(receiver instanceof P.Object))
+        return J.UnknownJavaScriptObject.prototype;
+      return receiver;
+    },
     getInterceptor$x: function(receiver) {
       if (receiver == null)
         return receiver;
@@ -2715,6 +2760,16 @@
         return receiver;
       return J.getNativeInterceptor(receiver);
     },
+    getInterceptor$z: function(receiver) {
+      if (receiver == null)
+        return receiver;
+      if (!(receiver instanceof P.Object))
+        return J.UnknownJavaScriptObject.prototype;
+      return receiver;
+    },
+    get$error$z: function(receiver) {
+      return J.getInterceptor$z(receiver).get$error(receiver);
+    },
     get$hashCode$: function(receiver) {
       return J.getInterceptor$(receiver).get$hashCode(receiver);
     },
@@ -2743,9 +2798,15 @@
     addEventListener$3$x: function(receiver, a0, a1, a2) {
       return J.getInterceptor$x(receiver).addEventListener$3(receiver, a0, a1, a2);
     },
+    complete$1$z: function(receiver, a0) {
+      return J.getInterceptor$z(receiver).complete$1(receiver, a0);
+    },
     forEach$1$ax: function(receiver, a0) {
       return J.getInterceptor$ax(receiver).forEach$1(receiver, a0);
     },
+    matchAsPrefix$2$s: function(receiver, a0, a1) {
+      return J.getInterceptor$s(receiver).matchAsPrefix$2(receiver, a0, a1);
+    },
     toString$0$: function(receiver) {
       return J.getInterceptor$(receiver).toString$0(receiver);
     },
@@ -2880,7 +2941,43 @@
         if (stackTrace != null)
           return stackTrace;
       }
-      return C.C__StringStackTrace;
+      return C._StringStackTrace_3uE;
+    },
+    Future_Future$sync: function(computation, $T) {
+      var result, error, stackTrace, future, replacement, t1, t2, exception;
+      try {
+        result = computation.call$0();
+        if ($T._eval$1("Future<0>")._is(result))
+          return result;
+        else {
+          t1 = $T._as(result);
+          t2 = new P._Future($.Zone__current, $T._eval$1("_Future<0>"));
+          t2._state = 4;
+          t2._resultOrListeners = t1;
+          return t2;
+        }
+      } catch (exception) {
+        error = H.unwrapException(exception);
+        stackTrace = H.getTraceFromException(exception);
+        future = new P._Future($.Zone__current, $T._eval$1("_Future<0>"));
+        type$.Object._as(error);
+        type$.nullable_StackTrace._as(stackTrace);
+        replacement = null;
+        if (replacement != null)
+          future._asyncCompleteError$2(J.get$error$z(replacement), replacement.get$stackTrace());
+        else
+          future._asyncCompleteError$2(error, stackTrace);
+        return future;
+      }
+    },
+    Future_Future$value: function(value, $T) {
+      var t1 = value == null ? $T._as(value) : value,
+        t2 = new P._Future($.Zone__current, $T._eval$1("_Future<0>"));
+      t2._asyncComplete$1(t1);
+      return t2;
+    },
+    Completer_Completer: function($T) {
+      return new P._AsyncCompleter(new P._Future($.Zone__current, $T._eval$1("_Future<0>")), $T._eval$1("_AsyncCompleter<0>"));
     },
     _Future__chainCoreFuture: function(source, target) {
       var t1, t2, listeners;
@@ -3095,6 +3192,8 @@
     _nullDataHandler: function(value) {
     },
     _nullErrorHandler: function(error, stackTrace) {
+      type$.Object._as(error);
+      type$.StackTrace._as(stackTrace);
       P._rootHandleUncaughtError(null, null, $.Zone__current, error, stackTrace);
     },
     _nullDoneHandler: function() {
@@ -3209,6 +3308,10 @@
       this.future = t0;
       this.$ti = t1;
     },
+    _SyncCompleter: function _SyncCompleter(t0, t1) {
+      this.future = t0;
+      this.$ti = t1;
+    },
     _FutureListener: function _FutureListener(t0, t1, t2, t3, t4) {
       var _ = this;
       _._nextListener = null;
@@ -3564,6 +3667,12 @@
       t1 = result._contents;
       return t1.charCodeAt(0) == 0 ? t1 : t1;
     },
+    ListQueue$: function($E) {
+      return new P.ListQueue(P.List_List$filled(P.ListQueue__calculateCapacity(null), null, false, $E._eval$1("0?")), $E._eval$1("ListQueue<0>"));
+    },
+    ListQueue__calculateCapacity: function(initialCapacity) {
+      return 8;
+    },
     ListMixin: function ListMixin() {
     },
     MapBase: function MapBase() {
@@ -3574,13 +3683,28 @@
     },
     MapMixin: function MapMixin() {
     },
+    ListQueue: function ListQueue(t0, t1) {
+      var _ = this;
+      _._table = t0;
+      _._modificationCount = _._tail = _._head = 0;
+      _.$ti = t1;
+    },
+    _ListQueueIterator: function _ListQueueIterator(t0, t1, t2, t3, t4) {
+      var _ = this;
+      _._queue = t0;
+      _._end = t1;
+      _._modificationCount = t2;
+      _._position = t3;
+      _._collection$_current = null;
+      _.$ti = t4;
+    },
     _parseJson: function(source, reviver) {
       var e, exception, t1, parsed = null;
       try {
         parsed = JSON.parse(source);
       } catch (exception) {
         e = H.unwrapException(exception);
-        t1 = P.FormatException$(String(e));
+        t1 = P.FormatException$(String(e), null, null);
         throw H.wrapException(t1);
       }
       t1 = P._convertJsonToDartLazy(parsed);
@@ -3654,22 +3778,23 @@
       this._seen = t1;
       this._toEncodable = t2;
     },
-    int_parse: function(source) {
-      var value = H.Primitives_parseInt(source, null);
+    int_parse: function(source, radix) {
+      var value = H.Primitives_parseInt(source, radix);
       if (value != null)
         return value;
-      throw H.wrapException(P.FormatException$(source));
+      throw H.wrapException(P.FormatException$(source, null, null));
     },
     Error__objectToString: function(object) {
       if (object instanceof H.Closure)
         return object.toString$0(0);
       return "Instance of '" + H.Primitives_objectTypeName(object) + "'";
     },
-    List_List$filled: function($length, fill, $E) {
-      var result;
-      if ($length > 4294967295)
-        H.throwExpression(P.RangeError$range($length, 0, 4294967295, "length", null));
-      result = J.JSArray_markFixedList(H.setRuntimeTypeInfo(new Array($length), $E._eval$1("JSArray<0>")), $E);
+    List_List$filled: function($length, fill, growable, $E) {
+      var i,
+        result = growable ? J.JSArray_JSArray$growable($length, $E) : J.JSArray_JSArray$fixed($length, $E);
+      if ($length !== 0 && fill != null)
+        for (i = 0; i < result.length; ++i)
+          result[i] = fill;
       return result;
     },
     StringBuffer__writeAll: function(string, objects, separator) {
@@ -3738,6 +3863,9 @@
     ArgumentError$value: function(value, $name, message) {
       return new P.ArgumentError(true, value, $name, message);
     },
+    ArgumentError$notNull: function($name) {
+      return new P.ArgumentError(false, null, $name, "Must not be null");
+    },
     RangeError$: function(message) {
       var _null = null;
       return new P.RangeError(_null, _null, false, _null, _null, message);
@@ -3748,8 +3876,24 @@
     RangeError$range: function(invalidValue, minValue, maxValue, $name, message) {
       return new P.RangeError(minValue, maxValue, true, invalidValue, $name, "Invalid value");
     },
+    RangeError_checkValidRange: function(start, end, $length) {
+      if (0 > start || start > $length)
+        throw H.wrapException(P.RangeError$range(start, 0, $length, "start", null));
+      if (end != null) {
+        if (start > end || end > $length)
+          throw H.wrapException(P.RangeError$range(end, start, $length, "end", null));
+        return end;
+      }
+      return $length;
+    },
+    RangeError_checkNotNegative: function(value, $name) {
+      if (value < 0)
+        throw H.wrapException(P.RangeError$range(value, 0, null, $name, null));
+      return value;
+    },
     IndexError$: function(invalidValue, indexable, $name, message, $length) {
-      return new P.IndexError($length, true, invalidValue, $name, "Index out of range");
+      var t1 = H._asInt($length == null ? J.get$length$asx(indexable) : $length);
+      return new P.IndexError(t1, true, invalidValue, $name, "Index out of range");
     },
     UnsupportedError$: function(message) {
       return new P.UnsupportedError(message);
@@ -3763,8 +3907,8 @@
     ConcurrentModificationError$: function(modifiedObject) {
       return new P.ConcurrentModificationError(modifiedObject);
     },
-    FormatException$: function(message) {
-      return new P.FormatException(message);
+    FormatException$: function(message, source, offset) {
+      return new P.FormatException(message, source, offset);
     },
     DateTime: function DateTime(t0, t1) {
       this._value = t0;
@@ -3832,8 +3976,10 @@
     _Exception: function _Exception(t0) {
       this.message = t0;
     },
-    FormatException: function FormatException(t0) {
+    FormatException: function FormatException(t0, t1, t2) {
       this.message = t0;
+      this.source = t1;
+      this.offset = t2;
     },
     Iterable: function Iterable() {
     },
@@ -3841,7 +3987,8 @@
     },
     Object: function Object() {
     },
-    _StringStackTrace: function _StringStackTrace() {
+    _StringStackTrace: function _StringStackTrace(t0) {
+      this._stackTrace = t0;
     },
     StringBuffer: function StringBuffer(t0) {
       this._contents = t0;
@@ -4011,6 +4158,10 @@
       this.handleData = t0;
     }
   },
+  S = {AsyncMemoizer: function AsyncMemoizer(t0, t1) {
+      this._completer = t0;
+      this.$ti = t1;
+    }},
   Y = {Level: function Level(t0, t1) {
       this.name = t0;
       this.value = t1;
@@ -4035,6 +4186,23 @@
       this.name = t0;
     }
   },
+  O = {Pool: function Pool(t0, t1, t2, t3, t4) {
+      var _ = this;
+      _._requestedResources = t0;
+      _._onReleaseCallbacks = t1;
+      _._onReleaseCompleters = t2;
+      _._maxAllocatedResources = t3;
+      _._allocatedResources = 0;
+      _._timer = null;
+      _._closeMemo = t4;
+    }, Pool__runOnRelease_closure: function Pool__runOnRelease_closure(t0) {
+      this.$this = t0;
+    }, Pool__runOnRelease_closure0: function Pool__runOnRelease_closure0(t0) {
+      this.$this = t0;
+    }, PoolResource: function PoolResource(t0) {
+      this._pool = t0;
+      this._released = false;
+    }},
   M = {
     SseClient$: function(serverUrl) {
       var t1 = type$.String;
@@ -4063,6 +4231,11 @@
     SseClient__closure: function SseClient__closure(t0, t1) {
       this.$this = t0;
       this.error = t1;
+    },
+    SseClient__onOutgoingMessage_closure: function SseClient__onOutgoingMessage_closure(t0, t1, t2) {
+      this._box_0 = t0;
+      this.$this = t1;
+      this.message = t2;
     }
   },
   T = {
@@ -4105,7 +4278,7 @@
       this.channel = t0;
     }
   };
-  var holders = [C, H, J, P, W, Y, L, F, M, T, R, E];
+  var holders = [C, H, J, P, W, S, Y, L, F, O, M, T, R, E];
   hunkHelpers.setFunctionNamesIfNecessary(holders);
   var $ = {};
   H.JS_CONST.prototype = {};
@@ -4183,6 +4356,27 @@
         return receiver[t1 - 1];
       throw H.wrapException(H.IterableElementError_noElement());
     },
+    setRange$4: function(receiver, start, end, iterable, skipCount) {
+      var $length, otherList, t1, i;
+      H._arrayInstanceType(receiver)._eval$1("Iterable<1>")._as(iterable);
+      if (!!receiver.immutable$list)
+        H.throwExpression(P.UnsupportedError$("setRange"));
+      P.RangeError_checkValidRange(start, end, receiver.length);
+      $length = end - start;
+      if ($length === 0)
+        return;
+      P.RangeError_checkNotNegative(skipCount, "skipCount");
+      otherList = iterable;
+      t1 = J.getInterceptor$asx(otherList);
+      if (skipCount + $length > t1.get$length(otherList))
+        throw H.wrapException(H.IterableElementError_tooFew());
+      if (skipCount < start)
+        for (i = $length - 1; i >= 0; --i)
+          receiver[start + i] = t1.$index(otherList, skipCount + i);
+      else
+        for (i = 0; i < $length; ++i)
+          receiver[start + i] = t1.$index(otherList, skipCount + i);
+    },
     get$isNotEmpty: function(receiver) {
       return receiver.length !== 0;
     },
@@ -4329,14 +4523,36 @@
         throw H.wrapException(H.diagnoseIndexError(receiver, index));
       return receiver.charCodeAt(index);
     },
+    matchAsPrefix$2: function(receiver, string, start) {
+      var t1, i, _null = null;
+      if (start < 0 || start > string.length)
+        throw H.wrapException(P.RangeError$range(start, 0, string.length, _null, _null));
+      t1 = receiver.length;
+      if (start + t1 > string.length)
+        return _null;
+      for (i = 0; i < t1; ++i)
+        if (this.codeUnitAt$1(string, start + i) !== this._codeUnitAt$1(receiver, i))
+          return _null;
+      return new H.StringMatch(start, receiver);
+    },
     $add: function(receiver, other) {
       return receiver + other;
     },
-    startsWith$1: function(receiver, pattern) {
-      var otherLength = pattern.length;
-      if (otherLength > receiver.length)
-        return false;
-      return pattern === receiver.substring(0, otherLength);
+    startsWith$2: function(receiver, pattern, index) {
+      var endIndex;
+      type$.Pattern._as(pattern);
+      if (index < 0 || index > receiver.length)
+        throw H.wrapException(P.RangeError$range(index, 0, receiver.length, null, null));
+      if (typeof pattern == "string") {
+        endIndex = index + pattern.length;
+        if (endIndex > receiver.length)
+          return false;
+        return pattern === receiver.substring(index, endIndex);
+      }
+      return J.matchAsPrefix$2$s(pattern, receiver, index) != null;
+    },
+    startsWith$1: function($receiver, pattern) {
+      return this.startsWith$2($receiver, pattern, 0);
     },
     substring$2: function(receiver, startIndex, endIndex) {
       if (endIndex == null)
@@ -4376,13 +4592,21 @@
         return receiver;
       return this.$mul(padding, delta) + receiver;
     },
-    lastIndexOf$1: function(receiver, pattern) {
-      var start = receiver.length,
-        t1 = pattern.length;
-      if (start + t1 > start)
-        start -= t1;
+    lastIndexOf$2: function(receiver, pattern, start) {
+      var t1, t2;
+      if (start == null)
+        start = receiver.length;
+      else if (start < 0 || start > receiver.length)
+        throw H.wrapException(P.RangeError$range(start, 0, receiver.length, null, null));
+      t1 = pattern.length;
+      t2 = receiver.length;
+      if (start + t1 > t2)
+        start = t2 - t1;
       return receiver.lastIndexOf(pattern, start);
     },
+    lastIndexOf$1: function($receiver, pattern) {
+      return this.lastIndexOf$2($receiver, pattern, null);
+    },
     toString$0: function(receiver) {
       return receiver;
     },
@@ -4411,11 +4635,9 @@
   };
   H.nullFuture_closure.prototype = {
     call$0: function() {
-      var t1 = new P._Future($.Zone__current, type$._Future_Null);
-      t1._asyncComplete$1(null);
-      return t1;
+      return P.Future_Future$value(null, type$.Null);
     },
-    $signature: 12
+    $signature: 7
   };
   H.EfficientLengthIterable.prototype = {};
   H.ListIterable.prototype = {
@@ -4424,8 +4646,7 @@
       return new H.ListIterator(_this, _this.get$length(_this), H._instanceType(_this)._eval$1("ListIterator<ListIterable.E>"));
     },
     get$isEmpty: function(_) {
-      var t1 = this._parent;
-      return t1.get$length(t1) === 0;
+      return this.get$length(this) === 0;
     }
   };
   H.ListIterator.prototype = {
@@ -4782,7 +5003,7 @@
     call$1: function(o) {
       return this.getTag(o);
     },
-    $signature: 5
+    $signature: 8
   };
   H.initHooks_closure0.prototype = {
     call$2: function(o, tag) {
@@ -4796,6 +5017,7 @@
     },
     $signature: 14
   };
+  H.StringMatch.prototype = {};
   H.NativeTypedData.prototype = {};
   H.NativeTypedArray.prototype = {
     get$length: function(receiver) {
@@ -4901,7 +5123,7 @@
       t1.storedCallback = null;
       f.call$0();
     },
-    $signature: 6
+    $signature: 4
   };
   P._AsyncRun__initializeScheduleImmediate_closure.prototype = {
     call$1: function(callback) {
@@ -5006,14 +5228,12 @@
   };
   P._Completer.prototype = {
     completeError$2: function(error, stackTrace) {
-      var t1;
       H.checkNotNullable(error, "error", type$.Object);
-      t1 = this.future;
-      if (t1._state !== 0)
+      if (this.future._state !== 0)
         throw H.wrapException(P.StateError$("Future already completed"));
       if (stackTrace == null)
         stackTrace = P.AsyncError_defaultStackTrace(error);
-      t1._asyncCompleteError$2(error, stackTrace);
+      this._completeError$2(error, stackTrace);
     },
     completeError$1: function(error) {
       return this.completeError$2(error, null);
@@ -5032,6 +5252,23 @@
     },
     complete$0: function($receiver) {
       return this.complete$1($receiver, null);
+    },
+    _completeError$2: function(error, stackTrace) {
+      this.future._asyncCompleteError$2(error, stackTrace);
+    }
+  };
+  P._SyncCompleter.prototype = {
+    complete$1: function(_, value) {
+      var t2,
+        t1 = this.$ti;
+      t1._eval$1("1/?")._as(value);
+      t2 = this.future;
+      if (t2._state !== 0)
+        throw H.wrapException(P.StateError$("Future already completed"));
+      t2._complete$1(t1._eval$1("1/")._as(value));
+    },
+    _completeError$2: function(error, stackTrace) {
+      this.future._completeError$2(error, stackTrace);
     }
   };
   P._FutureListener.prototype = {
@@ -5258,13 +5495,13 @@
         t1._completeError$2(error, stackTrace);
       }
     },
-    $signature: 6
+    $signature: 4
   };
   P._Future__chainForeignFuture_closure0.prototype = {
     call$2: function(error, stackTrace) {
       this.$this._completeError$2(type$.Object._as(error), type$.StackTrace._as(stackTrace));
     },
-    $signature: 8
+    $signature: 5
   };
   P._Future__chainForeignFuture_closure1.prototype = {
     call$0: function() {
@@ -5654,7 +5891,7 @@
       $E._eval$1("0?")._as(futureValue);
       t1.resultValue = null;
       if (!$E._is(null))
-        throw H.wrapException(new P.ArgumentError(false, null, "futureValue", "Must not be null"));
+        throw H.wrapException(P.ArgumentError$notNull("futureValue"));
       t1.resultValue = $E._as(futureValue);
       result = new P._Future($.Zone__current, $E._eval$1("_Future<0>"));
       this.set$_onDone(new P._BufferingStreamSubscription_asFuture_closure(t1, result));
@@ -5798,7 +6035,7 @@
       else
         t1._completeError$2(error, stackTrace);
     },
-    $signature: 8
+    $signature: 5
   };
   P._BufferingStreamSubscription_asFuture__closure.prototype = {
     call$0: function() {
@@ -6078,7 +6315,7 @@
       t1._contents = t2 + ": ";
       t1._contents += H.S(v);
     },
-    $signature: 9
+    $signature: 10
   };
   P.MapMixin.prototype = {
     forEach$1: function(_, action) {
@@ -6103,6 +6340,98 @@
     },
     $isMap: 1
   };
+  P.ListQueue.prototype = {
+    get$iterator: function(_) {
+      var _this = this;
+      return new P._ListQueueIterator(_this, _this._tail, _this._modificationCount, _this._head, _this.$ti._eval$1("_ListQueueIterator<1>"));
+    },
+    get$isEmpty: function(_) {
+      return this._head === this._tail;
+    },
+    get$length: function(_) {
+      return (this._tail - this._head & this._table.length - 1) >>> 0;
+    },
+    elementAt$1: function(_, index) {
+      var t1, t2, t3, _this = this,
+        $length = _this.get$length(_this);
+      if (0 > index || index >= $length)
+        H.throwExpression(P.IndexError$(index, _this, "index", null, $length));
+      t1 = _this._table;
+      t2 = t1.length;
+      t3 = (_this._head + index & t2 - 1) >>> 0;
+      if (t3 < 0 || t3 >= t2)
+        return H.ioore(t1, t3);
+      return _this.$ti._precomputed1._as(t1[t3]);
+    },
+    toString$0: function(_) {
+      return P.IterableBase_iterableToFullString(this, "{", "}");
+    },
+    removeFirst$0: function() {
+      var t2, result, _this = this,
+        t1 = _this._head;
+      if (t1 === _this._tail)
+        throw H.wrapException(H.IterableElementError_noElement());
+      ++_this._modificationCount;
+      t2 = _this._table;
+      if (t1 >= t2.length)
+        return H.ioore(t2, t1);
+      result = _this.$ti._precomputed1._as(t2[t1]);
+      C.JSArray_methods.$indexSet(t2, t1, null);
+      _this._head = (_this._head + 1 & _this._table.length - 1) >>> 0;
+      return result;
+    },
+    _add$1: function(element) {
+      var t2, t3, newTable, split, _this = this,
+        t1 = _this.$ti;
+      t1._precomputed1._as(element);
+      C.JSArray_methods.$indexSet(_this._table, _this._tail, element);
+      t2 = _this._tail;
+      t3 = _this._table.length;
+      t2 = (t2 + 1 & t3 - 1) >>> 0;
+      _this._tail = t2;
+      if (_this._head === t2) {
+        newTable = P.List_List$filled(t3 * 2, null, false, t1._eval$1("1?"));
+        t1 = _this._table;
+        t2 = _this._head;
+        split = t1.length - t2;
+        C.JSArray_methods.setRange$4(newTable, 0, split, t1, t2);
+        C.JSArray_methods.setRange$4(newTable, split, split + _this._head, _this._table, 0);
+        _this._head = 0;
+        _this._tail = _this._table.length;
+        _this.set$_table(newTable);
+      }
+      ++_this._modificationCount;
+    },
+    set$_table: function(_table) {
+      this._table = this.$ti._eval$1("List<1?>")._as(_table);
+    },
+    $isQueue: 1
+  };
+  P._ListQueueIterator.prototype = {
+    get$current: function() {
+      return this.$ti._precomputed1._as(this._collection$_current);
+    },
+    moveNext$0: function() {
+      var t2, t3, _this = this,
+        t1 = _this._queue;
+      if (_this._modificationCount !== t1._modificationCount)
+        H.throwExpression(P.ConcurrentModificationError$(t1));
+      t2 = _this._position;
+      if (t2 === _this._end) {
+        _this.set$_collection$_current(null);
+        return false;
+      }
+      t3 = t1._table;
+      if (t2 >= t3.length)
+        return H.ioore(t3, t2);
+      _this.set$_collection$_current(t3[t2]);
+      _this._position = (_this._position + 1 & t1._table.length - 1) >>> 0;
+      return true;
+    },
+    set$_collection$_current: function(_current) {
+      this._collection$_current = this.$ti._eval$1("1?")._as(_current);
+    }
+  };
   P._JsonMap.prototype = {
     $index: function(_, key) {
       var result,
@@ -6172,7 +6501,7 @@
         t1 = t1.get$keys().elementAt$1(0, index);
       else {
         t1 = t1._computeKeys$0();
-        if (index >= t1.length)
+        if (index < 0 || index >= t1.length)
           return H.ioore(t1, index);
         t1 = t1[index];
       }
@@ -6227,94 +6556,86 @@
   P.JsonDecoder.prototype = {};
   P._JsonStringifier.prototype = {
     writeStringContent$1: function(s) {
-      var t1, offset, i, charCode, t2, t3,
+      var offset, i, charCode, t1, t2, _this = this,
         $length = s.length;
-      for (t1 = this._sink, offset = 0, i = 0; i < $length; ++i) {
+      for (offset = 0, i = 0; i < $length; ++i) {
         charCode = C.JSString_methods._codeUnitAt$1(s, i);
         if (charCode > 92) {
           if (charCode >= 55296) {
-            t2 = charCode & 64512;
-            if (t2 === 55296) {
-              t3 = i + 1;
-              t3 = !(t3 < $length && (C.JSString_methods._codeUnitAt$1(s, t3) & 64512) === 56320);
+            t1 = charCode & 64512;
+            if (t1 === 55296) {
+              t2 = i + 1;
+              t2 = !(t2 < $length && (C.JSString_methods._codeUnitAt$1(s, t2) & 64512) === 56320);
             } else
-              t3 = false;
-            if (!t3)
-              if (t2 === 56320) {
-                t2 = i - 1;
-                t2 = !(t2 >= 0 && (C.JSString_methods.codeUnitAt$1(s, t2) & 64512) === 55296);
+              t2 = false;
+            if (!t2)
+              if (t1 === 56320) {
+                t1 = i - 1;
+                t1 = !(t1 >= 0 && (C.JSString_methods.codeUnitAt$1(s, t1) & 64512) === 55296);
               } else
-                t2 = false;
+                t1 = false;
             else
-              t2 = true;
-            if (t2) {
+              t1 = true;
+            if (t1) {
               if (i > offset)
-                t1._contents += C.JSString_methods.substring$2(s, offset, i);
+                _this.writeStringSlice$3(s, offset, i);
               offset = i + 1;
-              t2 = t1._contents += H.Primitives_stringFromCharCode(92);
-              t2 += H.Primitives_stringFromCharCode(117);
-              t1._contents = t2;
-              t2 += H.Primitives_stringFromCharCode(100);
-              t1._contents = t2;
-              t3 = charCode >>> 8 & 15;
-              t2 += H.Primitives_stringFromCharCode(t3 < 10 ? 48 + t3 : 87 + t3);
-              t1._contents = t2;
-              t3 = charCode >>> 4 & 15;
-              t2 += H.Primitives_stringFromCharCode(t3 < 10 ? 48 + t3 : 87 + t3);
-              t1._contents = t2;
-              t3 = charCode & 15;
-              t1._contents = t2 + H.Primitives_stringFromCharCode(t3 < 10 ? 48 + t3 : 87 + t3);
+              _this.writeCharCode$1(92);
+              _this.writeCharCode$1(117);
+              _this.writeCharCode$1(100);
+              t1 = charCode >>> 8 & 15;
+              _this.writeCharCode$1(t1 < 10 ? 48 + t1 : 87 + t1);
+              t1 = charCode >>> 4 & 15;
+              _this.writeCharCode$1(t1 < 10 ? 48 + t1 : 87 + t1);
+              t1 = charCode & 15;
+              _this.writeCharCode$1(t1 < 10 ? 48 + t1 : 87 + t1);
             }
           }
           continue;
         }
         if (charCode < 32) {
           if (i > offset)
-            t1._contents += C.JSString_methods.substring$2(s, offset, i);
+            _this.writeStringSlice$3(s, offset, i);
           offset = i + 1;
-          t2 = t1._contents += H.Primitives_stringFromCharCode(92);
+          _this.writeCharCode$1(92);
           switch (charCode) {
             case 8:
-              t1._contents = t2 + H.Primitives_stringFromCharCode(98);
+              _this.writeCharCode$1(98);
               break;
             case 9:
-              t1._contents = t2 + H.Primitives_stringFromCharCode(116);
+              _this.writeCharCode$1(116);
               break;
             case 10:
-              t1._contents = t2 + H.Primitives_stringFromCharCode(110);
+              _this.writeCharCode$1(110);
               break;
             case 12:
-              t1._contents = t2 + H.Primitives_stringFromCharCode(102);
+              _this.writeCharCode$1(102);
               break;
             case 13:
-              t1._contents = t2 + H.Primitives_stringFromCharCode(114);
+              _this.writeCharCode$1(114);
               break;
             default:
-              t2 += H.Primitives_stringFromCharCode(117);
-              t1._contents = t2;
-              t2 += H.Primitives_stringFromCharCode(48);
-              t1._contents = t2;
-              t2 += H.Primitives_stringFromCharCode(48);
-              t1._contents = t2;
-              t3 = charCode >>> 4 & 15;
-              t2 += H.Primitives_stringFromCharCode(t3 < 10 ? 48 + t3 : 87 + t3);
-              t1._contents = t2;
-              t3 = charCode & 15;
-              t1._contents = t2 + H.Primitives_stringFromCharCode(t3 < 10 ? 48 + t3 : 87 + t3);
+              _this.writeCharCode$1(117);
+              _this.writeCharCode$1(48);
+              _this.writeCharCode$1(48);
+              t1 = charCode >>> 4 & 15;
+              _this.writeCharCode$1(t1 < 10 ? 48 + t1 : 87 + t1);
+              t1 = charCode & 15;
+              _this.writeCharCode$1(t1 < 10 ? 48 + t1 : 87 + t1);
               break;
           }
         } else if (charCode === 34 || charCode === 92) {
           if (i > offset)
-            t1._contents += C.JSString_methods.substring$2(s, offset, i);
+            _this.writeStringSlice$3(s, offset, i);
           offset = i + 1;
-          t2 = t1._contents += H.Primitives_stringFromCharCode(92);
-          t1._contents = t2 + H.Primitives_stringFromCharCode(charCode);
+          _this.writeCharCode$1(92);
+          _this.writeCharCode$1(charCode);
         }
       }
       if (offset === 0)
-        t1._contents += s;
+        _this.writeString$1(s);
       else if (offset < $length)
-        t1._contents += C.JSString_methods.substring$2(s, offset, $length);
+        _this.writeStringSlice$3(s, offset, $length);
     },
     _checkCycle$1: function(object) {
       var t1, t2, i, t3;
@@ -6351,22 +6672,21 @@
       if (typeof object == "number") {
         if (!isFinite(object))
           return false;
-        _this._sink._contents += C.JSNumber_methods.toString$0(object);
+        _this.writeNumber$1(object);
         return true;
       } else if (object === true) {
-        _this._sink._contents += "true";
+        _this.writeString$1("true");
         return true;
       } else if (object === false) {
-        _this._sink._contents += "false";
+        _this.writeString$1("false");
         return true;
       } else if (object == null) {
-        _this._sink._contents += "null";
+        _this.writeString$1("null");
         return true;
       } else if (typeof object == "string") {
-        t1 = _this._sink;
-        t1._contents += '"';
+        _this.writeString$1('"');
         _this.writeStringContent$1(object);
-        t1._contents += '"';
+        _this.writeString$1('"');
         return true;
       } else if (type$.List_dynamic._is(object)) {
         _this._checkCycle$1(object);
@@ -6388,44 +6708,42 @@
         return false;
     },
     writeList$1: function(list) {
-      var t2, i,
-        t1 = this._sink;
-      t1._contents += "[";
-      t2 = J.getInterceptor$asx(list);
-      if (t2.get$isNotEmpty(list)) {
-        this.writeObject$1(t2.$index(list, 0));
-        for (i = 1; i < t2.get$length(list); ++i) {
-          t1._contents += ",";
-          this.writeObject$1(t2.$index(list, i));
+      var t1, i, _this = this;
+      _this.writeString$1("[");
+      t1 = J.getInterceptor$asx(list);
+      if (t1.get$isNotEmpty(list)) {
+        _this.writeObject$1(t1.$index(list, 0));
+        for (i = 1; i < t1.get$length(list); ++i) {
+          _this.writeString$1(",");
+          _this.writeObject$1(t1.$index(list, i));
         }
       }
-      t1._contents += "]";
+      _this.writeString$1("]");
     },
     writeMap$1: function(map) {
-      var t1, keyValueList, i, t2, separator, t3, _this = this, _box_0 = {};
+      var t1, keyValueList, i, separator, t2, _this = this, _box_0 = {};
       if (map.get$isEmpty(map)) {
-        _this._sink._contents += "{}";
+        _this.writeString$1("{}");
         return true;
       }
       t1 = map.get$length(map) * 2;
-      keyValueList = P.List_List$filled(t1, null, type$.nullable_Object);
+      keyValueList = P.List_List$filled(t1, null, false, type$.nullable_Object);
       i = _box_0.i = 0;
       _box_0.allStringKeys = true;
       map.forEach$1(0, new P._JsonStringifier_writeMap_closure(_box_0, keyValueList));
       if (!_box_0.allStringKeys)
         return false;
-      t2 = _this._sink;
-      t2._contents += "{";
+      _this.writeString$1("{");
       for (separator = '"'; i < t1; i += 2, separator = ',"') {
-        t2._contents += separator;
+        _this.writeString$1(separator);
         _this.writeStringContent$1(H._asString(keyValueList[i]));
-        t2._contents += '":';
-        t3 = i + 1;
-        if (t3 >= t1)
-          return H.ioore(keyValueList, t3);
-        _this.writeObject$1(keyValueList[t3]);
+        _this.writeString$1('":');
+        t2 = i + 1;
+        if (t2 >= t1)
+          return H.ioore(keyValueList, t2);
+        _this.writeObject$1(keyValueList[t2]);
       }
-      t2._contents += "}";
+      _this.writeString$1("}");
       return true;
     }
   };
@@ -6439,12 +6757,24 @@
       C.JSArray_methods.$indexSet(t1, t2.i++, key);
       C.JSArray_methods.$indexSet(t1, t2.i++, value);
     },
-    $signature: 9
+    $signature: 10
   };
   P._JsonStringStringifier.prototype = {
     get$_partialResult: function() {
       var t1 = this._sink._contents;
       return t1.charCodeAt(0) == 0 ? t1 : t1;
+    },
+    writeNumber$1: function(number) {
+      this._sink._contents += C.JSNumber_methods.toString$0(number);
+    },
+    writeString$1: function(string) {
+      this._sink._contents += string;
+    },
+    writeStringSlice$3: function(string, start, end) {
+      this._sink._contents += C.JSString_methods.substring$2(string, start, end);
+    },
+    writeCharCode$1: function(charCode) {
+      this._sink._contents += H.Primitives_stringFromCharCode(charCode);
     }
   };
   P.DateTime.prototype = {
@@ -6507,7 +6837,7 @@
         return "0000" + n;
       return "00000" + n;
     },
-    $signature: 10
+    $signature: 11
   };
   P.Duration_toString_twoDigits.prototype = {
     call$1: function(n) {
@@ -6515,7 +6845,7 @@
         return "" + n;
       return "0" + n;
     },
-    $signature: 10
+    $signature: 11
   };
   P.Error.prototype = {
     get$stackTrace: function() {
@@ -6548,7 +6878,7 @@
         $name = _this.name,
         nameString = $name == null ? "" : " (" + $name + ")",
         message = _this.message,
-        messageString = message == null ? "" : ": " + message,
+        messageString = message == null ? "" : ": " + H.S(message),
         prefix = _this.get$_errorName() + nameString + messageString;
       if (!_this._hasValue)
         return prefix;
@@ -6647,9 +6977,73 @@
   };
   P.FormatException.prototype = {
     toString$0: function(_) {
-      var message = this.message,
-        report = "" !== message ? "FormatException: " + message : "FormatException";
-      return report;
+      var t1, lineNum, lineStart, previousCharWasCR, i, char, lineEnd, end, start, prefix, postfix, slice,
+        message = this.message,
+        report = "" !== message ? "FormatException: " + message : "FormatException",
+        offset = this.offset,
+        source = this.source;
+      if (typeof source == "string") {
+        if (offset != null)
+          t1 = offset < 0 || offset > source.length;
+        else
+          t1 = false;
+        if (t1)
+          offset = null;
+        if (offset == null) {
+          if (source.length > 78)
+            source = C.JSString_methods.substring$2(source, 0, 75) + "...";
+          return report + "\n" + source;
+        }
+        for (lineNum = 1, lineStart = 0, previousCharWasCR = false, i = 0; i < offset; ++i) {
+          char = C.JSString_methods._codeUnitAt$1(source, i);
+          if (char === 10) {
+            if (lineStart !== i || !previousCharWasCR)
+              ++lineNum;
+            lineStart = i + 1;
+            previousCharWasCR = false;
+          } else if (char === 13) {
+            ++lineNum;
+            lineStart = i + 1;
+            previousCharWasCR = true;
+          }
+        }
+        report = lineNum > 1 ? report + (" (at line " + lineNum + ", character " + (offset - lineStart + 1) + ")\n") : report + (" (at character " + (offset + 1) + ")\n");
+        lineEnd = source.length;
+        for (i = offset; i < lineEnd; ++i) {
+          char = C.JSString_methods.codeUnitAt$1(source, i);
+          if (char === 10 || char === 13) {
+            lineEnd = i;
+            break;
+          }
+        }
+        if (lineEnd - lineStart > 78)
+          if (offset - lineStart < 75) {
+            end = lineStart + 75;
+            start = lineStart;
+            prefix = "";
+            postfix = "...";
+          } else {
+            if (lineEnd - offset < 75) {
+              start = lineEnd - 75;
+              end = lineEnd;
+              postfix = "";
+            } else {
+              start = offset - 36;
+              end = offset + 36;
+              postfix = "...";
+            }
+            prefix = "...";
+          }
+        else {
+          end = lineEnd;
+          start = lineStart;
+          prefix = "";
+          postfix = "";
+        }
+        slice = C.JSString_methods.substring$2(source, start, end);
+        return report + prefix + slice + postfix + "\n" + C.JSString_methods.$mul(" ", offset - start + prefix.length) + "^\n";
+      } else
+        return offset != null ? report + (" (at offset " + H.S(offset) + ")") : report;
     }
   };
   P.Iterable.prototype = {
@@ -6662,6 +7056,7 @@
     },
     elementAt$1: function(_, index) {
       var t1, elementIndex, element;
+      P.RangeError_checkNotNegative(index, "index");
       for (t1 = this.get$iterator(this), elementIndex = 0; t1.moveNext$0();) {
         element = t1.get$current();
         if (index === elementIndex)
@@ -6676,7 +7071,7 @@
   };
   P.Null.prototype = {
     get$hashCode: function(_) {
-      return P.Object.prototype.get$hashCode.call(this, this);
+      return P.Object.prototype.get$hashCode.call(C.JSNull_methods, this);
     },
     toString$0: function(_) {
       return "null";
@@ -6698,7 +7093,7 @@
   };
   P._StringStackTrace.prototype = {
     toString$0: function(_) {
-      return "";
+      return this._stackTrace;
     },
     $isStackTrace: 1
   };
@@ -7007,6 +7402,7 @@
       return new W._ElementEventStreamImpl(receiver, "click", false, type$._ElementEventStreamImpl_MouseEvent);
     }
   };
+  S.AsyncMemoizer.prototype = {};
   Y.Level.prototype = {
     $eq: function(_, other) {
       if (other == null)
@@ -7090,6 +7486,146 @@
     },
     $signature: 23
   };
+  O.Pool.prototype = {
+    request$0: function(_) {
+      var t1, t2, _this = this;
+      if (_this._closeMemo._completer.future._state !== 0)
+        throw H.wrapException(P.StateError$("request() may not be called on a closed Pool."));
+      t1 = _this._allocatedResources;
+      if (t1 < _this._maxAllocatedResources) {
+        _this._allocatedResources = t1 + 1;
+        return P.Future_Future$value(new O.PoolResource(_this), type$.PoolResource);
+      } else {
+        t1 = _this._onReleaseCallbacks;
+        if (!t1.get$isEmpty(t1))
+          return _this._runOnRelease$1(t1.removeFirst$0());
+        else {
+          t1 = new P._Future($.Zone__current, type$._Future_PoolResource);
+          t2 = _this._requestedResources;
+          t2._add$1(t2.$ti._precomputed1._as(new P._AsyncCompleter(t1, type$._AsyncCompleter_PoolResource)));
+          _this._resetTimer$0();
+          return t1;
+        }
+      }
+    },
+    withResource$1$1: function(callback, $T) {
+      return this.withResource$body$Pool($T._eval$1("0/()")._as(callback), $T, $T);
+    },
+    withResource$body$Pool: function(callback, $T, $async$type) {
+      var $async$goto = 0,
+        $async$completer = P._makeAsyncAwaitCompleter($async$type),
+        $async$returnValue, $async$handler = 2, $async$currentError, $async$next = [], $async$self = this, resource, t1, t2;
+      var $async$withResource$1$1 = P._wrapJsFunctionForAsync(function($async$errorCode, $async$result) {
+        if ($async$errorCode === 1) {
+          $async$currentError = $async$result;
+          $async$goto = $async$handler;
+        }
+        while (true)
+          switch ($async$goto) {
+            case 0:
+              // Function start
+              if ($async$self._closeMemo._completer.future._state !== 0)
+                throw H.wrapException(P.StateError$("withResource() may not be called on a closed Pool."));
+              $async$goto = 3;
+              return P._asyncAwait($async$self.request$0(0), $async$withResource$1$1);
+            case 3:
+              // returning from await.
+              resource = $async$result;
+              $async$handler = 4;
+              $async$goto = 7;
+              return P._asyncAwait(callback.call$0(), $async$withResource$1$1);
+            case 7:
+              // returning from await.
+              t1 = $async$result;
+              $async$returnValue = t1;
+              $async$next = [1];
+              // goto finally
+              $async$goto = 5;
+              break;
+              $async$next.push(6);
+              // goto finally
+              $async$goto = 5;
+              break;
+            case 4:
+              // uncaught
+              $async$next = [2];
+            case 5:
+              // finally
+              $async$handler = 2;
+              t1 = resource;
+              if (t1._released)
+                H.throwExpression(P.StateError$("A PoolResource may only be released once."));
+              t1._released = true;
+              t1 = t1._pool;
+              t1._resetTimer$0();
+              t2 = t1._requestedResources;
+              if (!t2.get$isEmpty(t2))
+                t2.removeFirst$0().complete$1(0, new O.PoolResource(t1));
+              else {
+                t2 = --t1._allocatedResources;
+                if (t1._closeMemo._completer.future._state !== 0 && t2 === 0)
+                  null.close$0(0);
+              }
+              // goto the next finally handler
+              $async$goto = $async$next.pop();
+              break;
+            case 6:
+              // after finally
+            case 1:
+              // return
+              return P._asyncReturn($async$returnValue, $async$completer);
+            case 2:
+              // rethrow
+              return P._asyncRethrow($async$currentError, $async$completer);
+          }
+      });
+      return P._asyncStartSync($async$withResource$1$1, $async$completer);
+    },
+    _runOnRelease$1: function(onRelease) {
+      var t2, t3,
+        t1 = P.Future_Future$sync(type$.dynamic_Function._as(onRelease), type$.dynamic).then$1$1(new O.Pool__runOnRelease_closure(this), type$.Null),
+        onError = new O.Pool__runOnRelease_closure0(this);
+      type$.nullable_bool_Function_Object._as(null);
+      t2 = t1.$ti;
+      t3 = $.Zone__current;
+      if (t3 !== C.C__RootZone)
+        onError = P._registerErrorHandler(onError, t3);
+      t1._addListener$1(new P._FutureListener(new P._Future(t3, t2), 2, null, onError, t2._eval$1("@<1>")._bind$1(t2._precomputed1)._eval$1("_FutureListener<1,2>")));
+      t1 = new P._Future($.Zone__current, type$._Future_PoolResource);
+      t2 = this._onReleaseCompleters;
+      t2._add$1(t2.$ti._precomputed1._as(new P._SyncCompleter(t1, type$._SyncCompleter_PoolResource)));
+      return t1;
+    },
+    _resetTimer$0: function() {
+      var t2,
+        t1 = this._timer;
+      if (t1 == null)
+        return;
+      t2 = this._requestedResources;
+      if (t2._head === t2._tail)
+        t1._restartable_timer$_timer.cancel$0();
+      else {
+        t1._restartable_timer$_timer.cancel$0();
+        t1._restartable_timer$_timer = P.Timer_Timer(t1._restartable_timer$_duration, t1._callback);
+      }
+    }
+  };
+  O.Pool__runOnRelease_closure.prototype = {
+    call$1: function(value) {
+      var t1 = this.$this;
+      J.complete$1$z(t1._onReleaseCompleters.removeFirst$0(), new O.PoolResource(t1));
+    },
+    $signature: 4
+  };
+  O.Pool__runOnRelease_closure0.prototype = {
+    call$2: function(error, stackTrace) {
+      type$.Object._as(error);
+      type$.StackTrace._as(stackTrace);
+      this.$this._onReleaseCompleters.removeFirst$0().completeError$2(error, stackTrace);
+    },
+    $signature: 5
+  };
+  O.PoolResource.prototype = {};
   M.SseClient.prototype = {
     get$_eventSource: function() {
       var t1 = this.__SseClient__eventSource;
@@ -7141,62 +7677,22 @@
     _onOutgoingMessage$body$SseClient: function(message) {
       var $async$goto = 0,
         $async$completer = P._makeAsyncAwaitCompleter(type$.dynamic),
-        $async$handler = 1, $async$currentError, $async$next = [], $async$self = this, e, e0, e1, exception, t1, encodedMessage, $async$exception;
+        $async$self = this, t1;
       var $async$_onOutgoingMessage$1 = P._wrapJsFunctionForAsync(function($async$errorCode, $async$result) {
-        if ($async$errorCode === 1) {
-          $async$currentError = $async$result;
-          $async$goto = $async$handler;
-        }
+        if ($async$errorCode === 1)
+          return P._asyncRethrow($async$result, $async$completer);
         while (true)
           switch ($async$goto) {
             case 0:
               // Function start
-              encodedMessage = null;
-              try {
-                encodedMessage = C.C_JsonCodec.encode$2$toEncodable(message, null);
-              } catch (exception) {
-                t1 = H.unwrapException(exception);
-                if (t1 instanceof P.JsonUnsupportedObjectError) {
-                  e = t1;
-                  $async$self._logger.log$4(C.Level_WARNING_900, "Unable to encode outgoing message: " + H.S(e), null, null);
-                } else if (t1 instanceof P.ArgumentError) {
-                  e0 = t1;
-                  $async$self._logger.log$4(C.Level_WARNING_900, "Invalid argument: " + H.S(e0), null, null);
-                } else
-                  throw exception;
-              }
-              $async$handler = 3;
-              t1 = $async$self.__SseClient__serverUrl;
-              $async$goto = 6;
-              return P._asyncAwait(W.HttpRequest_request((t1 == null ? H.throwExpression(H.LateError$fieldNI("_serverUrl")) : t1) + "&messageId=" + ++$async$self._lastMessageId, "POST", encodedMessage, true), $async$_onOutgoingMessage$1);
-            case 6:
-              // returning from await.
-              $async$handler = 1;
-              // goto after finally
-              $async$goto = 5;
-              break;
-            case 3:
-              // catch
-              $async$handler = 2;
-              $async$exception = $async$currentError;
-              e1 = H.unwrapException($async$exception);
-              $async$self._logger.log$4(C.Level_SEVERE_1000, "Failed to send " + H.S(message) + ":\n " + H.S(e1), null, null);
-              $async$self.close$0(0);
-              // goto after finally
-              $async$goto = 5;
-              break;
+              t1 = {};
+              t1.encodedMessage = null;
+              $async$goto = 2;
+              return P._asyncAwait($.$get$_requestPool().withResource$1$1(new M.SseClient__onOutgoingMessage_closure(t1, $async$self, message), type$.Null), $async$_onOutgoingMessage$1);
             case 2:
-              // uncaught
-              // goto rethrow
-              $async$goto = 1;
-              break;
-            case 5:
-              // after finally
+              // returning from await.
               // implicit return
               return P._asyncReturn(null, $async$completer);
-            case 1:
-              // rethrow
-              return P._asyncRethrow($async$currentError, $async$completer);
           }
       });
       return P._asyncStartSync($async$_onOutgoingMessage$1, $async$completer);
@@ -7252,6 +7748,73 @@
     },
     $signature: 0
   };
+  M.SseClient__onOutgoingMessage_closure.prototype = {
+    call$0: function() {
+      var $async$goto = 0,
+        $async$completer = P._makeAsyncAwaitCompleter(type$.Null),
+        $async$handler = 1, $async$currentError, $async$next = [], $async$self = this, e, e0, e1, exception, t1, t2, $async$exception;
+      var $async$call$0 = P._wrapJsFunctionForAsync(function($async$errorCode, $async$result) {
+        if ($async$errorCode === 1) {
+          $async$currentError = $async$result;
+          $async$goto = $async$handler;
+        }
+        while (true)
+          switch ($async$goto) {
+            case 0:
+              // Function start
+              try {
+                $async$self._box_0.encodedMessage = C.C_JsonCodec.encode$2$toEncodable($async$self.message, null);
+              } catch (exception) {
+                t1 = H.unwrapException(exception);
+                if (t1 instanceof P.JsonUnsupportedObjectError) {
+                  e = t1;
+                  $async$self.$this._logger.log$4(C.Level_WARNING_900, "Unable to encode outgoing message: " + H.S(e), null, null);
+                } else if (t1 instanceof P.ArgumentError) {
+                  e0 = t1;
+                  $async$self.$this._logger.log$4(C.Level_WARNING_900, "Invalid argument: " + H.S(e0), null, null);
+                } else
+                  throw exception;
+              }
+              $async$handler = 3;
+              t1 = $async$self.$this;
+              t2 = t1.__SseClient__serverUrl;
+              $async$goto = 6;
+              return P._asyncAwait(W.HttpRequest_request((t2 == null ? H.throwExpression(H.LateError$fieldNI("_serverUrl")) : t2) + "&messageId=" + ++t1._lastMessageId, "POST", $async$self._box_0.encodedMessage, true), $async$call$0);
+            case 6:
+              // returning from await.
+              $async$handler = 1;
+              // goto after finally
+              $async$goto = 5;
+              break;
+            case 3:
+              // catch
+              $async$handler = 2;
+              $async$exception = $async$currentError;
+              e1 = H.unwrapException($async$exception);
+              t1 = $async$self.$this;
+              t1._logger.log$4(C.Level_SEVERE_1000, "Failed to send " + H.S($async$self.message) + ":\n " + H.S(e1), null, null);
+              t1.close$0(0);
+              // goto after finally
+              $async$goto = 5;
+              break;
+            case 2:
+              // uncaught
+              // goto rethrow
+              $async$goto = 1;
+              break;
+            case 5:
+              // after finally
+              // implicit return
+              return P._asyncReturn(null, $async$completer);
+            case 1:
+              // rethrow
+              return P._asyncRethrow($async$currentError, $async$completer);
+          }
+      });
+      return P._asyncStartSync($async$call$0, $async$completer);
+    },
+    $signature: 7
+  };
   T.generateUuidV4__generateBits.prototype = {
     call$1: function(bitCount) {
       return this.random.nextInt$1(C.JSInt_methods._shlPositive$1(1, bitCount));
@@ -7262,13 +7825,13 @@
     call$2: function(value, count) {
       return C.JSString_methods.padLeft$2(C.JSInt_methods.toRadixString$1(value, 16), count, "0");
     },
-    $signature: 11
+    $signature: 12
   };
   T.generateUuidV4__bitsDigits.prototype = {
     call$2: function(bitCount, digitCount) {
       return this._printDigits.call$2(this._generateBits.call$1(bitCount), digitCount);
     },
-    $signature: 11
+    $signature: 12
   };
   R.StreamChannelMixin.prototype = {};
   E.main_closure.prototype = {
@@ -7283,7 +7846,7 @@
       var count, t1, t2, t3, i, t4, t5, lastEvent;
       H._asString(s);
       if (C.JSString_methods.startsWith$1(s, "send ")) {
-        count = P.int_parse(C.JSArray_methods.get$last(s.split(" ")));
+        count = P.int_parse(C.JSArray_methods.get$last(s.split(" ")), null);
         for (t1 = this.channel._outgoingController, t2 = H._instanceType(t1), t3 = t2._precomputed1, t2 = t2._eval$1("_DelayedData<1>"), i = 0; i < count; ++i) {
           t4 = t3._as("" + i);
           t5 = t1._state;
@@ -7324,16 +7887,16 @@
       _instance_2_u = hunkHelpers._instance_2u,
       _instance_1_u = hunkHelpers._instance_1u,
       _instance_0_u = hunkHelpers._instance_0u;
-    _static_1(P, "async__AsyncRun__scheduleImmediateJsOverride$closure", "_AsyncRun__scheduleImmediateJsOverride", 4);
-    _static_1(P, "async__AsyncRun__scheduleImmediateWithSetImmediate$closure", "_AsyncRun__scheduleImmediateWithSetImmediate", 4);
-    _static_1(P, "async__AsyncRun__scheduleImmediateWithTimer$closure", "_AsyncRun__scheduleImmediateWithTimer", 4);
+    _static_1(P, "async__AsyncRun__scheduleImmediateJsOverride$closure", "_AsyncRun__scheduleImmediateJsOverride", 6);
+    _static_1(P, "async__AsyncRun__scheduleImmediateWithSetImmediate$closure", "_AsyncRun__scheduleImmediateWithSetImmediate", 6);
+    _static_1(P, "async__AsyncRun__scheduleImmediateWithTimer$closure", "_AsyncRun__scheduleImmediateWithTimer", 6);
     _static_0(P, "async___startMicrotaskLoop$closure", "_startMicrotaskLoop", 0);
     _static_1(P, "async___nullDataHandler$closure", "_nullDataHandler", 2);
-    _static_2(P, "async___nullErrorHandler$closure", "_nullErrorHandler", 7);
+    _static_2(P, "async___nullErrorHandler$closure", "_nullErrorHandler", 9);
     _static_0(P, "async___nullDoneHandler$closure", "_nullDoneHandler", 0);
     _instance(P._Completer.prototype, "get$completeError", 0, 1, null, ["call$2", "call$1"], ["completeError$2", "completeError$1"], 18, 0);
-    _instance_2_u(P._Future.prototype, "get$_completeError", "_completeError$2", 7);
-    _static_1(P, "convert___defaultToEncodable$closure", "_defaultToEncodable", 5);
+    _instance_2_u(P._Future.prototype, "get$_completeError", "_completeError$2", 9);
+    _static_1(P, "convert___defaultToEncodable$closure", "_defaultToEncodable", 8);
     var _;
     _instance_1_u(_ = M.SseClient.prototype, "get$_onIncomingControlMessage", "_onIncomingControlMessage$1", 1);
     _instance_1_u(_, "get$_onIncomingMessage", "_onIncomingMessage$1", 1);
@@ -7345,13 +7908,13 @@
       _inherit = hunkHelpers.inherit,
       _inheritMany = hunkHelpers.inheritMany;
     _inherit(P.Object, null);
-    _inheritMany(P.Object, [H.JS_CONST, J.Interceptor, J.ArrayIterator, P.Error, H.Closure, P.Iterable, H.ListIterator, H.FixedLengthListMixin, H.TypeErrorDecoder, H.NullThrownFromJavaScriptException, H.ExceptionAndStackTrace, H._StackTrace, P.MapMixin, H.LinkedHashMapCell, H.LinkedHashMapKeyIterator, H.Rti, H._FunctionParameters, P._TimerImpl, P._AsyncAwaitCompleter, P.AsyncError, P._Completer, P._FutureListener, P._Future, P._AsyncCallbackEntry, P.Stream, P.StreamSubscription, P.StreamTransformerBase, P._StreamController, P._AsyncStreamControllerDispatch, P._BufferingStreamSubscription, P._StreamSinkWrapper, P._DelayedEvent, P._DelayedDone, P._PendingEvents, P._StreamIterator, P._Zone, P.ListMixin, P.Codec, P._JsonStringifier, P.DateTime, P.Duration, P.OutOfMemoryError, P.StackOverflowError, P._Exception, P.FormatException, P.Null, P._StringStackTrace, P.StringBuffer, W.EventStreamProvider, P._AcceptStructuredClone, P.NullRejectionException, P._JSRandom, Y.Level, L.LogRecord, F.Logger, R.StreamChannelMixin]);
+    _inheritMany(P.Object, [H.JS_CONST, J.Interceptor, J.ArrayIterator, P.Error, H.Closure, P.Iterable, H.ListIterator, H.FixedLengthListMixin, H.TypeErrorDecoder, H.NullThrownFromJavaScriptException, H.ExceptionAndStackTrace, H._StackTrace, P.MapMixin, H.LinkedHashMapCell, H.LinkedHashMapKeyIterator, H.StringMatch, H.Rti, H._FunctionParameters, P._TimerImpl, P._AsyncAwaitCompleter, P.AsyncError, P._Completer, P._FutureListener, P._Future, P._AsyncCallbackEntry, P.Stream, P.StreamSubscription, P.StreamTransformerBase, P._StreamController, P._AsyncStreamControllerDispatch, P._BufferingStreamSubscription, P._StreamSinkWrapper, P._DelayedEvent, P._DelayedDone, P._PendingEvents, P._StreamIterator, P._Zone, P.ListMixin, P._ListQueueIterator, P.Codec, P._JsonStringifier, P.DateTime, P.Duration, P.OutOfMemoryError, P.StackOverflowError, P._Exception, P.FormatException, P.Null, P._StringStackTrace, P.StringBuffer, W.EventStreamProvider, P._AcceptStructuredClone, P.NullRejectionException, P._JSRandom, S.AsyncMemoizer, Y.Level, L.LogRecord, F.Logger, O.Pool, O.PoolResource, R.StreamChannelMixin]);
     _inheritMany(J.Interceptor, [J.JSBool, J.JSNull, J.JavaScriptObject, J.JSArray, J.JSNumber, J.JSString, H.NativeTypedData, W.EventTarget, W.DomException, W.Event]);
     _inheritMany(J.JavaScriptObject, [J.PlainJavaScriptObject, J.UnknownJavaScriptObject, J.JavaScriptFunction]);
     _inherit(J.JSUnmodifiableArray, J.JSArray);
     _inheritMany(J.JSNumber, [J.JSInt, J.JSNumNotInt]);
     _inheritMany(P.Error, [H.LateError, P.TypeError, H.JsNoSuchMethodError, H.UnknownJsTypeError, H.RuntimeError, P.AssertionError, H._Error, P.JsonUnsupportedObjectError, P.NullThrownError, P.ArgumentError, P.UnsupportedError, P.UnimplementedError, P.StateError, P.ConcurrentModificationError, P.CyclicInitializationError]);
-    _inheritMany(H.Closure, [H.nullFuture_closure, H.TearOffClosure, H.initHooks_closure, H.initHooks_closure0, H.initHooks_closure1, P._AsyncRun__initializeScheduleImmediate_internalCallback, P._AsyncRun__initializeScheduleImmediate_closure, P._AsyncRun__scheduleImmediateJsOverride_internalCallback, P._AsyncRun__scheduleImmediateWithSetImmediate_internalCallback, P._TimerImpl_internalCallback, P._awaitOnObject_closure, P._awaitOnObject_closure0, P._wrapJsFunctionForAsync_closure, P._Future__addListener_closure, P._Future__prependListeners_closure, P._Future__chainForeignFuture_closure, P._Future__chainForeignFuture_closure0, P._Future__chainForeignFuture_closure1, P._Future__asyncCompleteWithValue_closure, P._Future__chainFuture_closure, P._Future__asyncCompleteError_closure, P._Future__propagateToListeners_handleWhenCompleteCallback, P._Future__propagateToListeners_handleWhenCompleteCallback_closure, P._Future__propagateToListeners_handleValueCallback, P._Future__propagateToListeners_handleError, P.Stream_length_closure, P.Stream_length_closure0, P.Stream_first_closure, P.Stream_first_closure0, P._StreamController__subscribe_closure, P._StreamController__recordCancel_complete, P._BufferingStreamSubscription_asFuture_closure, P._BufferingStreamSubscription_asFuture_closure0, P._BufferingStreamSubscription_asFuture__closure, P._BufferingStreamSubscription__sendError_sendError, P._BufferingStreamSubscription__sendDone_sendDone, P._PendingEvents_schedule_closure, P._cancelAndValue_closure, P._rootHandleUncaughtError_closure, P._RootZone_bindCallbackGuarded_closure, P._RootZone_bindUnaryCallbackGuarded_closure, P.MapBase_mapToString_closure, P._JsonStringifier_writeMap_closure, P.Duration_toString_sixDigits, P.Duration_toString_twoDigits, W.HttpRequest_request_closure, W._EventStreamSubscription_closure, W._EventStreamSubscription_onData_closure, P._AcceptStructuredClone_walk_closure, P._convertDartToNative_Value_closure, P.convertDartToNative_Dictionary_closure, P.promiseToFuture_closure, P.promiseToFuture_closure0, F.Logger_Logger_closure, M.SseClient_closure, M.SseClient_closure0, M.SseClient_closure1, M.SseClient__closure, T.generateUuidV4__generateBits, T.generateUuidV4__printDigits, T.generateUuidV4__bitsDigits, E.main_closure, E.main_closure0]);
+    _inheritMany(H.Closure, [H.nullFuture_closure, H.TearOffClosure, H.initHooks_closure, H.initHooks_closure0, H.initHooks_closure1, P._AsyncRun__initializeScheduleImmediate_internalCallback, P._AsyncRun__initializeScheduleImmediate_closure, P._AsyncRun__scheduleImmediateJsOverride_internalCallback, P._AsyncRun__scheduleImmediateWithSetImmediate_internalCallback, P._TimerImpl_internalCallback, P._awaitOnObject_closure, P._awaitOnObject_closure0, P._wrapJsFunctionForAsync_closure, P._Future__addListener_closure, P._Future__prependListeners_closure, P._Future__chainForeignFuture_closure, P._Future__chainForeignFuture_closure0, P._Future__chainForeignFuture_closure1, P._Future__asyncCompleteWithValue_closure, P._Future__chainFuture_closure, P._Future__asyncCompleteError_closure, P._Future__propagateToListeners_handleWhenCompleteCallback, P._Future__propagateToListeners_handleWhenCompleteCallback_closure, P._Future__propagateToListeners_handleValueCallback, P._Future__propagateToListeners_handleError, P.Stream_length_closure, P.Stream_length_closure0, P.Stream_first_closure, P.Stream_first_closure0, P._StreamController__subscribe_closure, P._StreamController__recordCancel_complete, P._BufferingStreamSubscription_asFuture_closure, P._BufferingStreamSubscription_asFuture_closure0, P._BufferingStreamSubscription_asFuture__closure, P._BufferingStreamSubscription__sendError_sendError, P._BufferingStreamSubscription__sendDone_sendDone, P._PendingEvents_schedule_closure, P._cancelAndValue_closure, P._rootHandleUncaughtError_closure, P._RootZone_bindCallbackGuarded_closure, P._RootZone_bindUnaryCallbackGuarded_closure, P.MapBase_mapToString_closure, P._JsonStringifier_writeMap_closure, P.Duration_toString_sixDigits, P.Duration_toString_twoDigits, W.HttpRequest_request_closure, W._EventStreamSubscription_closure, W._EventStreamSubscription_onData_closure, P._AcceptStructuredClone_walk_closure, P._convertDartToNative_Value_closure, P.convertDartToNative_Dictionary_closure, P.promiseToFuture_closure, P.promiseToFuture_closure0, F.Logger_Logger_closure, O.Pool__runOnRelease_closure, O.Pool__runOnRelease_closure0, M.SseClient_closure, M.SseClient_closure0, M.SseClient_closure1, M.SseClient__closure, M.SseClient__onOutgoingMessage_closure, T.generateUuidV4__generateBits, T.generateUuidV4__printDigits, T.generateUuidV4__bitsDigits, E.main_closure, E.main_closure0]);
     _inherit(H.EfficientLengthIterable, P.Iterable);
     _inheritMany(H.EfficientLengthIterable, [H.ListIterable, H.LinkedHashMapKeyIterable]);
     _inherit(H.NullError, P.TypeError);
@@ -7367,7 +7930,7 @@
     _inherit(H.NativeTypedArrayOfInt, H._NativeTypedArrayOfInt_NativeTypedArray_ListMixin_FixedLengthListMixin);
     _inheritMany(H.NativeTypedArrayOfInt, [H.NativeInt16List, H.NativeInt32List, H.NativeInt8List, H.NativeUint16List, H.NativeUint32List, H.NativeUint8ClampedList, H.NativeUint8List]);
     _inherit(H._TypeError, H._Error);
-    _inherit(P._AsyncCompleter, P._Completer);
+    _inheritMany(P._Completer, [P._AsyncCompleter, P._SyncCompleter]);
     _inherit(P._AsyncStreamController, P._StreamController);
     _inheritMany(P.Stream, [P._StreamImpl, W._EventStream]);
     _inherit(P._ControllerStream, P._StreamImpl);
@@ -7375,7 +7938,7 @@
     _inheritMany(P._DelayedEvent, [P._DelayedData, P._DelayedError]);
     _inherit(P._StreamImplEvents, P._PendingEvents);
     _inherit(P._RootZone, P._Zone);
-    _inherit(P._JsonMapKeyIterable, H.ListIterable);
+    _inheritMany(H.ListIterable, [P.ListQueue, P._JsonMapKeyIterable]);
     _inherit(P.Converter, P.StreamTransformerBase);
     _inherit(P.JsonCyclicError, P.JsonUnsupportedObjectError);
     _inherit(P.JsonCodec, P.Codec);
@@ -7405,13 +7968,13 @@
     mangledNames: {},
     getTypeFromName: getGlobalFromName,
     metadata: [],
-    types: ["~()", "~(Event)", "~(@)", "Null()", "~(~())", "@(@)", "Null(@)", "~(Object,StackTrace)", "Null(Object,StackTrace)", "~(Object?,Object?)", "String(int)", "String(int,int)", "Future<Null>()", "@(@,String)", "@(String)", "Null(~())", "Null(@,StackTrace)", "~(int,@)", "~(Object[StackTrace?])", "_Future<@>(@)", "~(ProgressEvent)", "@(@,@)", "~(@,@)", "Logger()", "~(String?)", "int(int)", "~(MouseEvent)", "~(String)"],
+    types: ["~()", "~(Event)", "~(@)", "Null()", "Null(@)", "Null(Object,StackTrace)", "~(~())", "Future<Null>()", "@(@)", "~(Object,StackTrace)", "~(Object?,Object?)", "String(int)", "String(int,int)", "@(@,String)", "@(String)", "Null(~())", "Null(@,StackTrace)", "~(int,@)", "~(Object[StackTrace?])", "_Future<@>(@)", "~(ProgressEvent)", "@(@,@)", "~(@,@)", "Logger()", "~(String?)", "int(int)", "~(MouseEvent)", "~(String)"],
     interceptorsByTag: null,
     leafTags: null,
     arrayRti: typeof Symbol == "function" && typeof Symbol() == "symbol" ? Symbol("$ti") : "$ti"
   };
-  H._Universe_addRules(init.typeUniverse, JSON.parse('{"PlainJavaScriptObject":"JavaScriptObject","UnknownJavaScriptObject":"JavaScriptObject","JavaScriptFunction":"JavaScriptObject","AbortPaymentEvent":"Event","ExtendableEvent":"Event","AElement":"SvgElement","GraphicsElement":"SvgElement","_ResourceProgressEvent":"ProgressEvent","AudioElement":"HtmlElement","MediaElement":"HtmlElement","PointerEvent":"MouseEvent","CompositionEvent":"UIEvent","MessagePort":"EventTarget","HtmlDocument":"Node","Document":"Node","NativeFloat32List":"NativeTypedArrayOfDouble","JSBool":{"bool":[]},"JSNull":{"Null":[]},"JSArray":{"List":["1"],"Iterable":["1"]},"JSUnmodifiableArray":{"JSArray":["1"],"List":["1"],"Iterable":["1"]},"JSNumber":{"double":[],"num":[]},"JSInt":{"double":[],"int":[],"num":[]},"JSNumNotInt":{"double":[],"num":[]},"JSString":{"String":[],"Pattern":[]},"LateError":{"Error":[]},"EfficientLengthIterable":{"Iterable":["1"]},"ListIterable":{"Iterable":["1"]},"NullError":{"Error":[]},"JsNoSuchMethodError":{"Error":[]},"UnknownJsTypeError":{"Error":[]},"_StackTrace":{"StackTrace":[]},"Closure":{"Function":[]},"TearOffClosure":{"Function":[]},"StaticClosure":{"Function":[]},"BoundClosure":{"Function":[]},"RuntimeError":{"Error":[]},"_AssertionError":{"Error":[]},"JsLinkedHashMap":{"MapMixin":["1","2"],"LinkedHashMap":["1","2"],"Map":["1","2"],"MapMixin.K":"1","MapMixin.V":"2"},"LinkedHashMapKeyIterable":{"Iterable":["1"]},"NativeTypedArray":{"JavaScriptIndexingBehavior":["1"]},"NativeTypedArrayOfDouble":{"ListMixin":["double"],"JavaScriptIndexingBehavior":["double"],"List":["double"],"Iterable":["double"],"FixedLengthListMixin":["double"],"ListMixin.E":"double"},"NativeTypedArrayOfInt":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"]},"NativeInt16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8ClampedList":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"_Error":{"Error":[]},"_TypeError":{"Error":[]},"_Future":{"Future":["1"]},"_TimerImpl":{"Timer":[]},"_AsyncAwaitCompleter":{"Completer":["1"]},"AsyncError":{"Error":[]},"_Completer":{"Completer":["1"]},"_AsyncCompleter":{"_Completer":["1"],"Completer":["1"]},"_StreamController":{"StreamController":["1"],"_StreamControllerLifecycle":["1"],"_EventDispatch":["1"]},"_AsyncStreamController":{"_AsyncStreamControllerDispatch":["1"],"_StreamController":["1"],"StreamController":["1"],"_StreamControllerLifecycle":["1"],"_EventDispatch":["1"]},"_ControllerStream":{"_StreamImpl":["1"],"Stream":["1"]},"_ControllerSubscription":{"_BufferingStreamSubscription":["1"],"StreamSubscription":["1"],"_EventDispatch":["1"]},"_BufferingStreamSubscription":{"StreamSubscription":["1"],"_EventDispatch":["1"]},"_StreamImpl":{"Stream":["1"]},"_DelayedData":{"_DelayedEvent":["1"]},"_DelayedError":{"_DelayedEvent":["@"]},"_DelayedDone":{"_DelayedEvent":["@"]},"_StreamImplEvents":{"_PendingEvents":["1"]},"_Zone":{"Zone":[]},"_RootZone":{"_Zone":[],"Zone":[]},"MapBase":{"MapMixin":["1","2"],"Map":["1","2"]},"MapMixin":{"Map":["1","2"]},"_JsonMap":{"MapMixin":["String","@"],"Map":["String","@"],"MapMixin.K":"String","MapMixin.V":"@"},"_JsonMapKeyIterable":{"ListIterable":["String"],"Iterable":["String"],"ListIterable.E":"String"},"JsonUnsupportedObjectError":{"Error":[]},"JsonCyclicError":{"Error":[]},"JsonEncoder":{"Converter":["Object?","String"]},"JsonDecoder":{"Converter":["String","Object?"]},"double":{"num":[]},"int":{"num":[]},"String":{"Pattern":[]},"AssertionError":{"Error":[]},"TypeError":{"Error":[]},"NullThrownError":{"Error":[]},"ArgumentError":{"Error":[]},"RangeError":{"Error":[]},"IndexError":{"Error":[]},"UnsupportedError":{"Error":[]},"UnimplementedError":{"Error":[]},"StateError":{"Error":[]},"ConcurrentModificationError":{"Error":[]},"OutOfMemoryError":{"Error":[]},"StackOverflowError":{"Error":[]},"CyclicInitializationError":{"Error":[]},"_StringStackTrace":{"StackTrace":[]},"StringBuffer":{"StringSink":[]},"HttpRequest":{"EventTarget":[]},"HttpRequestEventTarget":{"EventTarget":[]},"MouseEvent":{"Event":[]},"ProgressEvent":{"Event":[]},"UIEvent":{"Event":[]},"HtmlElement":{"Element":[],"EventTarget":[]},"AnchorElement":{"Element":[],"EventTarget":[]},"AreaElement":{"Element":[],"EventTarget":[]},"Element":{"EventTarget":[]},"EventSource":{"EventTarget":[]},"FormElement":{"Element":[],"EventTarget":[]},"MessageEvent":{"Event":[]},"Node":{"EventTarget":[]},"SelectElement":{"Element":[],"EventTarget":[]},"_EventStream":{"Stream":["1"]},"_ElementEventStreamImpl":{"_EventStream":["1"],"Stream":["1"]},"_EventStreamSubscription":{"StreamSubscription":["1"]},"SvgElement":{"Element":[],"EventTarget":[]}}'));
-  H._Universe_addErasedTypes(init.typeUniverse, JSON.parse('{"EfficientLengthIterable":1,"NativeTypedArray":1,"StreamTransformerBase":2,"MapBase":2,"Codec":2,"StreamChannelMixin":1}'));
+  H._Universe_addRules(init.typeUniverse, JSON.parse('{"PlainJavaScriptObject":"JavaScriptObject","UnknownJavaScriptObject":"JavaScriptObject","JavaScriptFunction":"JavaScriptObject","AbortPaymentEvent":"Event","ExtendableEvent":"Event","AElement":"SvgElement","GraphicsElement":"SvgElement","_ResourceProgressEvent":"ProgressEvent","AudioElement":"HtmlElement","MediaElement":"HtmlElement","PointerEvent":"MouseEvent","CompositionEvent":"UIEvent","MessagePort":"EventTarget","HtmlDocument":"Node","Document":"Node","NativeFloat32List":"NativeTypedArrayOfDouble","JSBool":{"bool":[]},"JSNull":{"Null":[]},"JSArray":{"List":["1"],"Iterable":["1"]},"JSUnmodifiableArray":{"JSArray":["1"],"List":["1"],"Iterable":["1"]},"JSNumber":{"double":[],"num":[]},"JSInt":{"double":[],"int":[],"num":[]},"JSNumNotInt":{"double":[],"num":[]},"JSString":{"String":[],"Pattern":[]},"LateError":{"Error":[]},"EfficientLengthIterable":{"Iterable":["1"]},"ListIterable":{"Iterable":["1"]},"NullError":{"Error":[]},"JsNoSuchMethodError":{"Error":[]},"UnknownJsTypeError":{"Error":[]},"_StackTrace":{"StackTrace":[]},"Closure":{"Function":[]},"TearOffClosure":{"Function":[]},"StaticClosure":{"Function":[]},"BoundClosure":{"Function":[]},"RuntimeError":{"Error":[]},"_AssertionError":{"Error":[]},"JsLinkedHashMap":{"MapMixin":["1","2"],"LinkedHashMap":["1","2"],"Map":["1","2"],"MapMixin.K":"1","MapMixin.V":"2"},"LinkedHashMapKeyIterable":{"Iterable":["1"]},"NativeTypedArray":{"JavaScriptIndexingBehavior":["1"]},"NativeTypedArrayOfDouble":{"ListMixin":["double"],"JavaScriptIndexingBehavior":["double"],"List":["double"],"Iterable":["double"],"FixedLengthListMixin":["double"],"ListMixin.E":"double"},"NativeTypedArrayOfInt":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"]},"NativeInt16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeInt8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint16List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint32List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8ClampedList":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"NativeUint8List":{"ListMixin":["int"],"JavaScriptIndexingBehavior":["int"],"List":["int"],"Iterable":["int"],"FixedLengthListMixin":["int"],"ListMixin.E":"int"},"_Error":{"Error":[]},"_TypeError":{"Error":[]},"_Future":{"Future":["1"]},"_TimerImpl":{"Timer":[]},"_AsyncAwaitCompleter":{"Completer":["1"]},"AsyncError":{"Error":[]},"_Completer":{"Completer":["1"]},"_AsyncCompleter":{"_Completer":["1"],"Completer":["1"]},"_SyncCompleter":{"_Completer":["1"],"Completer":["1"]},"_StreamController":{"StreamController":["1"],"_StreamControllerLifecycle":["1"],"_EventDispatch":["1"]},"_AsyncStreamController":{"_AsyncStreamControllerDispatch":["1"],"_StreamController":["1"],"StreamController":["1"],"_StreamControllerLifecycle":["1"],"_EventDispatch":["1"]},"_ControllerStream":{"_StreamImpl":["1"],"Stream":["1"]},"_ControllerSubscription":{"_BufferingStreamSubscription":["1"],"StreamSubscription":["1"],"_EventDispatch":["1"]},"_BufferingStreamSubscription":{"StreamSubscription":["1"],"_EventDispatch":["1"]},"_StreamImpl":{"Stream":["1"]},"_DelayedData":{"_DelayedEvent":["1"]},"_DelayedError":{"_DelayedEvent":["@"]},"_DelayedDone":{"_DelayedEvent":["@"]},"_StreamImplEvents":{"_PendingEvents":["1"]},"_Zone":{"Zone":[]},"_RootZone":{"_Zone":[],"Zone":[]},"MapBase":{"MapMixin":["1","2"],"Map":["1","2"]},"MapMixin":{"Map":["1","2"]},"ListQueue":{"ListIterable":["1"],"Queue":["1"],"Iterable":["1"],"ListIterable.E":"1"},"_JsonMap":{"MapMixin":["String","@"],"Map":["String","@"],"MapMixin.K":"String","MapMixin.V":"@"},"_JsonMapKeyIterable":{"ListIterable":["String"],"Iterable":["String"],"ListIterable.E":"String"},"JsonUnsupportedObjectError":{"Error":[]},"JsonCyclicError":{"Error":[]},"JsonCodec":{"Codec":["Object?","String"]},"JsonEncoder":{"Converter":["Object?","String"]},"JsonDecoder":{"Converter":["String","Object?"]},"double":{"num":[]},"int":{"num":[]},"String":{"Pattern":[]},"AssertionError":{"Error":[]},"TypeError":{"Error":[]},"NullThrownError":{"Error":[]},"ArgumentError":{"Error":[]},"RangeError":{"Error":[]},"IndexError":{"Error":[]},"UnsupportedError":{"Error":[]},"UnimplementedError":{"Error":[]},"StateError":{"Error":[]},"ConcurrentModificationError":{"Error":[]},"OutOfMemoryError":{"Error":[]},"StackOverflowError":{"Error":[]},"CyclicInitializationError":{"Error":[]},"_StringStackTrace":{"StackTrace":[]},"StringBuffer":{"StringSink":[]},"HttpRequest":{"EventTarget":[]},"HttpRequestEventTarget":{"EventTarget":[]},"MouseEvent":{"Event":[]},"ProgressEvent":{"Event":[]},"UIEvent":{"Event":[]},"HtmlElement":{"Element":[],"EventTarget":[]},"AnchorElement":{"Element":[],"EventTarget":[]},"AreaElement":{"Element":[],"EventTarget":[]},"Element":{"EventTarget":[]},"EventSource":{"EventTarget":[]},"FormElement":{"Element":[],"EventTarget":[]},"MessageEvent":{"Event":[]},"Node":{"EventTarget":[]},"SelectElement":{"Element":[],"EventTarget":[]},"_EventStream":{"Stream":["1"]},"_ElementEventStreamImpl":{"_EventStream":["1"],"Stream":["1"]},"_EventStreamSubscription":{"StreamSubscription":["1"]},"SvgElement":{"Element":[],"EventTarget":[]}}'));
+  H._Universe_addErasedTypes(init.typeUniverse, JSON.parse('{"EfficientLengthIterable":1,"NativeTypedArray":1,"StreamTransformerBase":2,"MapBase":2,"StreamChannelMixin":1}'));
   0;
   var type$ = (function rtii() {
     var findType = H.findType;
@@ -7436,20 +7999,24 @@
       MouseEvent: findType("MouseEvent"),
       Null: findType("Null"),
       Object: findType("Object"),
+      Pattern: findType("Pattern"),
+      PoolResource: findType("PoolResource"),
       ProgressEvent: findType("ProgressEvent"),
       StackTrace: findType("StackTrace"),
       String: findType("String"),
       UnknownJavaScriptObject: findType("UnknownJavaScriptObject"),
       _AsyncCompleter_HttpRequest: findType("_AsyncCompleter<HttpRequest>"),
+      _AsyncCompleter_PoolResource: findType("_AsyncCompleter<PoolResource>"),
       _AsyncCompleter_dynamic: findType("_AsyncCompleter<@>"),
       _ElementEventStreamImpl_MouseEvent: findType("_ElementEventStreamImpl<MouseEvent>"),
       _EventStream_Event: findType("_EventStream<Event>"),
       _Future_HttpRequest: findType("_Future<HttpRequest>"),
-      _Future_Null: findType("_Future<Null>"),
+      _Future_PoolResource: findType("_Future<PoolResource>"),
       _Future_dynamic: findType("_Future<@>"),
       _Future_int: findType("_Future<int>"),
       _Future_void: findType("_Future<~>"),
       _StreamControllerAddStreamState_nullable_Object: findType("_StreamControllerAddStreamState<Object?>"),
+      _SyncCompleter_PoolResource: findType("_SyncCompleter<PoolResource>"),
       bool: findType("bool"),
       bool_Function_Object: findType("bool(Object)"),
       double: findType("double"),
@@ -7464,8 +8031,10 @@
       nullable_Future_Null: findType("Future<Null>?"),
       nullable_List_dynamic: findType("List<@>?"),
       nullable_Object: findType("Object?"),
+      nullable_StackTrace: findType("StackTrace?"),
       nullable__DelayedEvent_dynamic: findType("_DelayedEvent<@>?"),
       nullable__FutureListener_dynamic_dynamic: findType("_FutureListener<@,@>?"),
+      nullable_bool_Function_Object: findType("bool(Object)?"),
       nullable_dynamic_Function_Event: findType("@(Event)?"),
       nullable_nullable_Object_Function_2_nullable_Object_and_nullable_Object: findType("Object?(Object?,Object?)?"),
       nullable_nullable_Object_Function_dynamic: findType("Object?(@)?"),
@@ -7486,6 +8055,7 @@
     C.Interceptor_methods = J.Interceptor.prototype;
     C.JSArray_methods = J.JSArray.prototype;
     C.JSInt_methods = J.JSInt.prototype;
+    C.JSNull_methods = J.JSNull.prototype;
     C.JSNumber_methods = J.JSNumber.prototype;
     C.JSString_methods = J.JSString.prototype;
     C.JavaScriptFunction_methods = J.JavaScriptFunction.prototype;
@@ -7616,7 +8186,6 @@
     C.C__DelayedDone = new P._DelayedDone();
     C.C__JSRandom = new P._JSRandom();
     C.C__RootZone = new P._RootZone();
-    C.C__StringStackTrace = new P._StringStackTrace();
     C.Duration_0 = new P.Duration(0);
     C.Duration_5000000 = new P.Duration(5000000);
     C.JsonDecoder_null = new P.JsonDecoder(null);
@@ -7624,6 +8193,7 @@
     C.Level_INFO_800 = new Y.Level("INFO", 800);
     C.Level_SEVERE_1000 = new Y.Level("SEVERE", 1000);
     C.Level_WARNING_900 = new Y.Level("WARNING", 900);
+    C._StringStackTrace_3uE = new P._StringStackTrace("");
   })();
   (function staticFields() {
     $._JS_INTEROP_INTERCEPTOR_TAG = null;
@@ -7722,7 +8292,7 @@
       return P._AsyncRun__initializeScheduleImmediate();
     });
     _lazyFinal($, "Future__nullFuture", "$get$Future__nullFuture", function() {
-      return type$._Future_Null._as($.$get$nullFuture());
+      return H.findType("_Future<Null>")._as($.$get$nullFuture());
     });
     _lazy($, "_hasErrorStackProperty", "$get$_hasErrorStackProperty", function() {
       return new Error().stack != void 0;
@@ -7730,6 +8300,15 @@
     _lazyFinal($, "Logger_root", "$get$Logger_root", function() {
       return F.Logger_Logger("");
     });
+    _lazyFinal($, "_requestPool", "$get$_requestPool", function() {
+      var t4,
+        t1 = H.findType("Completer<PoolResource>"),
+        t2 = P.ListQueue$(t1),
+        t3 = P.ListQueue$(type$.void_Function);
+      t1 = P.ListQueue$(t1);
+      t4 = P.Completer_Completer(type$.dynamic);
+      return new O.Pool(t2, t3, t1, 1000, new S.AsyncMemoizer(t4, H.findType("AsyncMemoizer<@>")));
+    });
   })();
   (function nativeSupport() {
     !function() {