-
Notifications
You must be signed in to change notification settings - Fork 512
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Throws TypeError: Illegal invocation
on deno deploy
#367
Comments
From my point of view, it's a bug in Deno deploy (maybe related to denoland/deno#12353?). However, I made this portion of code more robust to circumvent it in the version 2.6.28 I just deployed. I did a test in Deno Playground with the code below and it works now as expected. import { serve } from "https://deno.land/std@0.145.0/http/server.ts";
import {
BlobReader,
BlobWriter,
TextReader,
TextWriter,
ZipReader,
ZipWriter,
} from "https://deno.land/x/zipjs/index.js";
serve(async req => {
// ----
// Write the zip file
// ----
// Creates a BlobWriter object where the zip content will be written.
const zipFileWriter = new BlobWriter();
// Creates a TextReader object storing the text of the entry to add in the zip
// (i.e. "Hello world!").
const helloWorldReader = new TextReader("Hello world!");
// Creates a ZipWriter object writing data via `zipFileWriter`, adds the entry
// "hello.txt" containing the text "Hello world!" via `helloWorldReader`, and
// closes the writer.
const zipWriter = new ZipWriter(zipFileWriter);
await zipWriter.add("hello.txt", helloWorldReader);
await zipWriter.close();
// Retrieves the Blob object containing the zip content into `zipFileBlob`. It
// is also returned by zipWriter.close() for more convenience.
const zipFileBlob = await zipFileWriter.getData();
// ----
// Read the zip file
// ----
// Creates a BlobReader object used to read `zipFileBlob`.
const zipFileReader = new BlobReader(zipFileBlob);
// Creates a TextWriter object where the content of the first entry in the zip
// will be written.
const helloWorldWriter = new TextWriter();
// Creates a ZipReader object reading the zip content via `zipFileReader`,
// retrieves metadata (name, dates, etc.) of the first entry, retrieves its
// content via `helloWorldWriter`, and closes the reader.
const zipReader = new ZipReader(zipFileReader);
const firstEntry = (await zipReader.getEntries()).shift();
const helloWorldText = await firstEntry.getData(helloWorldWriter);
await zipReader.close();
// Displays "Hello world!".
return new Response(helloWorldText);
}); |
For the record, I reported this issue here: denoland/deploy_feedback#287. |
I completely agree that it's a problem with Deno Deploy. But it doesn't seem like they're going to fix those bugs anytime soon, so something had to be done on the library side. Thank you for the quick response and solution. |
@SaadiSave FYI, the bug has been fixed in Deno Deploy. |
I deployed a script on deno deploy today and noticed the following error:
The exception seems to be caused by this code in
lib/core/configuration.js
The text was updated successfully, but these errors were encountered: