Skip to content
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

error: Uncaught AssertionError: Unexpected skip of the emit. #6082

Closed
denjucks opened this issue Jun 3, 2020 · 14 comments · Fixed by #6177
Closed

error: Uncaught AssertionError: Unexpected skip of the emit. #6082

denjucks opened this issue Jun 3, 2020 · 14 comments · Fixed by #6177
Assignees
Labels
bug Something isn't working correctly cli related to cli/ dir

Comments

@denjucks
Copy link

denjucks commented Jun 3, 2020

Receiving this error when importing a file. It looks like the issue is isolated to Linux

error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///mydir/__anonymous__:1:1

Code to reproduce this error on Linux:

import Dex from "https://deno.land/x/dex/mod.ts";

Will look into it further and see if I can isolate the bug a bit.

@bartlomieju bartlomieju added bug Something isn't working correctly cli related to cli/ dir labels Jun 3, 2020
@bartlomieju bartlomieju self-assigned this Jun 3, 2020
@denjucks
Copy link
Author

denjucks commented Jun 3, 2020

Here's a more isolated example. I took a module I wrote about a month ago that performs base64 encoding, removed any external modules from it (was only using the path module prior), and then tried to import it and run it, and it throw the above error:

mod.ts

/**
 * Encodes a Uint8Array into a base64 string
 *
 * @private
 *
 * @param {any} uint8arr a Uint8Array
 * @returns {string} a base64 encoded string 
 */
function _encodeU8intToBase64String(uint8arr: any) : string {
	const CHUNK_SIZE = 0x8000;
	
	const charArray: string[] = [];
	
	for (let i = 0; i < uint8arr.length; i += CHUNK_SIZE) {
		charArray.push(String.fromCharCode.apply(null, uint8arr.subarray(i, i + CHUNK_SIZE)));
	}
	
	return btoa(charArray.join(""));
}


/**
 * Converts a string to a Uint8Array
 *
 * @private
 *
 * @param {string} str a string
 * @returns {Uint8Array} a Uint8Array from the string 
 */
function _convertStringToUint8(str: string) : Uint8Array {
	return new Uint8Array(new TextEncoder().encode(str))
}


/**
 * Decodes a UInt8Array that contains base64 data into a base64 decoded string
 *
 * @private
 *
 * @param {Uint8Array} bytes a Uint8Array that contains base64 encoded data
 * @returns {string} an base64 unencoded string 
 */
function _decodeBase64Bytes(bytes: Uint8Array) : string {
	return new TextDecoder().decode(Uint8Array.from(atob(new TextDecoder().decode(bytes)), c => c.charCodeAt(0)))
}


/**
 * Decodes a Uint8Array that contains base64 data into a base64 decoded Uint8Array
 *
 * @private
 *
 * @param {Uint8Array} bytes a Uint8Array that contains base64 encoded data
 * @returns {Uint8Array} an base64 unencoded Uint8Array 
 */
function _decodeBase64BytesToUint8(bytes: Uint8Array) : Uint8Array {
	return Uint8Array.from(atob(new TextDecoder().decode(bytes)), c => c.charCodeAt(0));
}



/**
 * This class provides an easy interface to perform base64 encoding on strings
 * and files.
 */
export class Base64 {
	
	private bytes: Uint8Array;
	private mime: string;
	private isBase64Encoded: boolean;
	
	public constructor(data: any) {
		this.bytes = data.bytes;
		this.mime = data.mime;
		this.isBase64Encoded = data.isBase64Encoded;
	}
	
	
	/**
	 * Creates a Base64 object from a string
	 *
	 * @public
	 * @static
	 *
	 * @param {string} unencodedString a string that will be base64 encoded
	 * @returns {Base64} a Base64 object
	 */
	public static fromString(unencodedString: string) : Base64 {
		return new Base64({
			bytes: _convertStringToUint8(unencodedString),
			mime: null,
			isBase64Encoded: false,
		});
	}
	
	
	/**
	 * Creates a Base64 object from an already base64 encoded string
	 *
	 * @public
	 * @static
	 *
	 * @param {string} encodedString a string that is already base64 encoded
	 * @returns {Base64} a Base64 object
	 */
	public static fromBase64String(encodedString: string) : Base64 {
		return new Base64({
			bytes: _convertStringToUint8(encodedString),
			mime: null,
			isBase64Encoded: true,
		});
	}
	
	
	/**
	 * Creates a Base64 object from a Uint8Array
	 *
	 * @public
	 * @static
	 *
	 * @param {Uint8Array} uint8arr a Uint8Array that will be base64 encoded
	 * @returns {Base64} a Base64 object
	 */
	public static fromUint8Array(uint8arr: Uint8Array) : Base64 {
		return new Base64({
			bytes: uint8arr,
			mime: null,
			isBase64Encoded: false,
		});
	}
	

	/**
	 * Creates a Base64 object from a base64 encoded Uint8Array
	 *
	 * @public
	 * @static
	 *
	 * @param {Uint8Array} uint8arr a Uint8Array that contains base64 encoded data
	 * @returns {Base64} a Base64 object
	 */
	public static fromBase64Uint8Array(uint8arr: Uint8Array) : Base64 {
		return new Base64({
			bytes: uint8arr,
			mime: null,
			isBase64Encoded: true,
		});
	}
	
	
	

	
	
	/**
	 * Returns the base64 encoded string from the Base64 object
	 *
	 * @public
	 *
	 * @returns {Base64} a base64 encoded string
	 */
	public toString() : string {
		if (this.isBase64Encoded) {
			return _decodeBase64Bytes(this.bytes);
		} else {
			return _encodeU8intToBase64String(this.bytes);
		}
	}
	
	
	/**
	 * Returns the base64 encoded string from the Base64 object, with the
	 * inclusion of the MIME type if the Base64 object was created from a file
	 * (and if not created from a file, works the same as the .toString() method)
	 *
	 * @public
	 *
	 * @returns {string} a base64 encoded string with MIME type included when from a file
	 */
	public toStringWithMime() : string {
		if (this.mime) {
			if (this.isBase64Encoded) {
				return _decodeBase64Bytes(this.bytes);
			} else {
				return this.mime + _encodeU8intToBase64String(this.bytes);
			}
			
		} else {
			if (this.isBase64Encoded) {
				return _decodeBase64Bytes(this.bytes);
			} else {
				return _encodeU8intToBase64String(this.bytes);
			}
		}
	}
}

test.js

import { Base64 } from "./mod.ts";

console.log(Base64.fromString("hello world").toString());

@nayeemrmn
Copy link
Collaborator

I reproduced this here: #5982 (comment). I put it in that issue because it seems connected.

@ChristopherMeek
Copy link

I can reproduce on windows

import { sprintf } from "https://deno.land/std/fmt/printf.ts";

Compile file:///D:/Projects/deno/example.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///D:/Projects/deno/__anonymous__:1:1```

@ry ry mentioned this issue Jun 5, 2020
6 tasks
@edgarasben
Copy link

Getting the same on mac:

Compile file:///Users/edgaras/Documents/Sites/deno-sandbox/app.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///Users/edgaras/Documents/Sites/deno-sandbox/__anonymous__:1:1

@taisukef
Copy link
Contributor

taisukef commented Jun 8, 2020

This is the minimum error code. (save as "test.js", and "deno run test.js")

import { exp } from "https://taisukef.github.io/denolib/test_mod.ts";

test_mod.ts is the just bellow

export const exp = {};

import ts from js -- NG
import ts from mjs -- OK
import ts from cjs -- OK
import ts from ts -- OK
import mjs from js-- OK
import ts (local) from js -- OK

1.0.3 -- OK
1.0.4 -- NG
1.0.5 -- NG

@bartlomieju
Copy link
Member

Update: I'm looking into this issue and found root cause. Fix will be released in Deno 1.1 in a few days.

@chimemoo
Copy link

chimemoo commented Jun 9, 2020

Im also geting this error on windows

Compile file:///D:/Deno/diplodocus/app.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///D:/Deno/diplodocus/__anonymous__:1:1

@harmeet-sawlani
Copy link

error: Uncaught AssertionError: Unexpected skip of the emit.
at Object.assert ($deno$/util.ts:33:11)
at compile ($deno$/compiler.ts:1170:7)
at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
at file:///C:/Project/Deno/denoreact/anonymous:1:1

Facing same issue for "https://deno.land/x/abc@v1.0.0-rc10/mod.ts"

@aeonincode
Copy link

same in mac

$ deno run deno2.js
Download https://deno.land/std/examples/welcome.ts
Warning Implicitly using master branch https://deno.land/std/examples/welcome.ts
Compile file:///Users/khashayar/Desktop/deno2.js
error: Uncaught AssertionError: Unexpected skip of the emit.
at Object.assert ($deno$/util.ts:33:11)
at compile ($deno$/compiler.ts:1170:7)
at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
at file:///Users/khashayar/Desktop/anonymous:1:1

@letowebdev
Copy link

letowebdev commented Jun 11, 2020

Windows using Deno 1.0.5

import "https://deno.land/std/examples/welcome.ts"

$ deno run --allow-net deno2.js

output:
Compile file:///F:/ALL%20XAMPP/new/3/XAMPP/htdocs/Deno%20PlayGround/denoFirstApp/deno2.js
error: Uncaught AssertionError: Unexpected skip of the emit.
at Object.assert ($deno$/util.ts:33:11)
at compile ($deno$/compiler.ts:1170:7)
at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
at file:///F:/ALL%20XAMPP/new/3/XAMPP/htdocs/Deno%20PlayGround/denoFirstApp/anonymous:1:1

@AndrewBogdanovTSS
Copy link

It's happening to me when I import ts file into file with js extension.
Drakefile.js

import { desc, run, task, sh } from "https://deno.land/x/drake@v1.2.2/mod.ts"

desc("Minimal Drake task")
task("hello", [], async function(){
  console.log("Hello from Drake!")
  await sh('deno run --allow-env index.ts')
})

run()

deno run -A Drakefile.js hello

Renaming to .ts helped me

@edgarasben
Copy link

Getting the same on mac:

Compile file:///Users/edgaras/Documents/Sites/deno-sandbox/app.js
error: Uncaught AssertionError: Unexpected skip of the emit.
    at Object.assert ($deno$/util.ts:33:11)
    at compile ($deno$/compiler.ts:1170:7)
    at tsCompilerOnMessage ($deno$/compiler.ts:1338:22)
    at workerMessageRecvCallback ($deno$/runtime_worker.ts:72:33)
    at file:///Users/edgaras/Documents/Sites/deno-sandbox/__anonymous__:1:1

1.1 update fixed it for me! Thanks, Bartek!

@hayd
Copy link
Contributor

hayd commented Jun 12, 2020

deno-lambda too! 👍

@tksilicon
Copy link

Got the emit error too but upgrading to Deno 1.1.1 fixed it.

Compile file:///Users/frankukachukwu/oss/dso/deps.ts
error: Uncaught AssertionError: Unexpected skip of the emit.
at Object.assert ($deno$/util.ts:33:11)
at compile ($deno$/compiler.ts:1345:7)
at async tsCompilerOnMessage ($deno$/compiler.ts:1548:22)
at async workerMessageRecvCallback ($deno$/runtime_worker.ts:74:9)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly cli related to cli/ dir
Projects
None yet