Skip to content

Commit

Permalink
Merge pull request rustwasm#1235 from fitzgen/some-little-things
Browse files Browse the repository at this point in the history
A couple small improvements
  • Loading branch information
alexcrichton authored Feb 11, 2019
2 parents f6362a6 + 4975ca2 commit 311dafd
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion crates/cli-support/src/js/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,17 @@ impl<'a> Context<'a> {
memory = __exports.memory = {init_memory};
const response = fetch(module_or_path);
if (typeof WebAssembly.instantiateStreaming === 'function') {{
result = WebAssembly.instantiateStreaming(response, imports);
result = WebAssembly.instantiateStreaming(response, imports)
.catch(e => {{
console.warn(\"`WebAssembly.instantiateStreaming` failed. Assuming this is \
because your server does not serve wasm with \
`application/wasm` MIME type. Falling back to \
`WebAssembly.instantiate` which is slower. Original \
error:\\n\", e);
return response
.then(r => r.arrayBuffer())
.then(bytes => WebAssembly.instantiate(bytes, imports));
}});
}} else {{
result = response
.then(r => r.arrayBuffer())
Expand Down
2 changes: 1 addition & 1 deletion crates/js-sys/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4339,7 +4339,7 @@ impl From<String> for JsString {

impl<'a> From<&'a JsString> for String {
fn from(s: &'a JsString) -> Self {
s.obj.as_string().unwrap()
s.obj.as_string().unwrap_throw()
}
}

Expand Down

0 comments on commit 311dafd

Please sign in to comment.