Skip to content

Does console.log work within greenlet? #6

@tommy-mitchell

Description

@tommy-mitchell

I'm not sure if this is a limitation of this library or of Workers in general, but I was expecting the following code to log each index:

import { greenlet } from "tinylet";

const func = greenlet(() => {
	let count = 0;

	for (let i = 0; i < 1000; i++) {
		count = i + 1;
		console.log(`Item: ${i}`);
	}

	return count;
});

const count = await func();
console.log({ count });

However, the actual output is:

Item: 0
{ count: 1000 }

Why does it only log inside of the worker once?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions