Skip to content

Sometimes Clearscript throw out this exception, even in 7.5.0 #651

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

Closed
nluyan opened this issue Mar 27, 2025 · 4 comments
Closed

Sometimes Clearscript throw out this exception, even in 7.5.0 #651

nluyan opened this issue Mar 27, 2025 · 4 comments

Comments

@nluyan
Copy link

nluyan commented Mar 27, 2025

Error: 由于线程退出或应用程序请求,已中止 I/O 操作。
at V8ScriptEngine [internal]:1:896 -> Object.defineProperty(this,'EngineInternal',{value:(t=>{let e=t=>t.bind();function r(){return new this(...arguments)}let o=t.isHostObjectKey;delete t.isHostObjectKey;let n=t=>!!t&&!0===t[o],c=Promise,i=JSON,a=Symbol(),s=t.toJson;return delete t.toJson,Object.freeze({commandHolder:{},getCommandResult:e(t=>null==t?t:'function'!=typeof t.hasOwnProperty?'Module'===t[Symbol.toStringTag]?'[module]':'[external]':!0===t[o]?t:'function'!=typeof t.toString?'['+typeof t+']':t.toString()),strictEquals:e((t,e)=>t===e),invokeConstructor:e((t,e)=>{if('function'!=typeof t)throw Error('Function expected');return r.apply(t,Array.from(e))}),invokeMethod:e((t,e,r)=>{if('function'!=typeof e)throw Error('Function expected');return e.apply(t,Array.from(r))}),createPromise:e(function(){return new c(...arguments)}),isPromise:e(t=>t instanceof c),isHostObject:e(n),completePromiseWithResult:e((t,e,r)=>{try{e(t())}catch(o){r(o)}}),completePromise:e((t,e,r)=>{try{t(),e()}catch(o){r(o)}}),throwValue:e(t=>{throw t}),getStackTrace:e(()=>{try{throw Error('[stack trace]')}catch(t){return t.stack}}),toIterator:e(function*(t){try{for(;t.ScriptableMoveNext();)yield t.ScriptableCurrent}finally{t.ScriptableDispose()}}),toAsyncIterator:e(async function*(t){try{for(;await t.ScriptableMoveNextAsync();)yield t.ScriptableCurrent}finally{await t.ScriptableDisposeAsync()}}),getIterator:e(t=>t?.[Symbol.iterator]?.()),getAsyncIterator:e(t=>t?.[Symbol.asyncIterator]?.()),checkpoint:e(()=>{let e=t[a];if(e)throw e}),toJson:e((t,e)=>s?i.parse(s(t,e)):e),parseJson:e(t=>i.parse(t)),asyncGenerator:async function*(){}().constructor})})(this)});

@ClearScriptLib
Copy link
Collaborator

Hi @nluyan,

That's most likely an instance of System.IO.IOException that did not originate from ClearScript. It looks like it was thrown from a .NET task that had been converted to a JavaScript promise.

That's all we can tell from the above. A .NET stack trace might provide more information. If you can share a minimal app that reproduces the issue, we'll be happy to take a look at it.

Thanks!

@nluyan
Copy link
Author

nluyan commented Mar 30, 2025

here is my code:

const handle = async (req, res) => {
    let db = new Database();
    var userInfo = await db.queryOne("select * from sys_user where user_name = @username",
        { '@username': req.body.username });

    if (userInfo != null) {
        var roles = await db.query(`
            SELECT sys_user.user_id, sys_user.user_name, sys_role.role_key, sys_role.role_name
            FROM sys_user
            LEFT JOIN sys_user_role ON sys_user.user_id = sys_user_role.user_id
            LEFT JOIN sys_role ON sys_user_role.role_id = sys_role.role_id
            WHERE sys_user.user_id = @userId
            `, { '@userId': userInfo.user_id });
        let token = createJwtToken(
            new Date(new Date().getTime() + 24 * 60 * 60 * 1000),
            roles.map(c => c.role_key),
            null,
            {
                'name': userInfo.user_name,
                'id': userInfo.user_id,
                'uid': '00000000000000000000000000'
            }
        );

        //await res.render('test', { title: 'this is a test' });
        await res.send({ code: 200, msg: 'sucess', token: token });
    }
    else
        await res.send({ code: 400, msg: 'failed' });
};

Database class wrapped a .net objet(__database), it query data from mysql, basiclly like this:

async queryOne(sql: string, parameters: any = null): Promise<any> {
        return JSON.parse(await __database.QueryOne2Async(this.connectionName, sql, parameters));
    }

It not always happen, so I can't figure out the patterns.
but it seems only happen in windows environment, in my linux system, I don't come across this exception yet.
when the exception has been thrown out, then it will be thrown at this evaluation every time, until restart asp.net application.

@ClearScriptLib
Copy link
Collaborator

Hi @nluyan,

Thanks for posting the code above. Unfortunately, it isn't enough for us to reproduce the issue. If you can't post a full working sample, could you provide a .NET stack trace of the point at which the exception is first thrown?

All we have so far is the message string from the JavaScript exception wrapper, which doesn't tell us much. Knowing the exact type and stack of the underlying .NET exception could be very helpful.

Thanks!

@ClearScriptLib
Copy link
Collaborator

Please reopen this issue if you have additional information about this topic. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants