Closed afranz33 closed 2 years ago
Can you isolate and provide the offending input javascript which is causing this?
Yes, the signalr.js file I downloaded from the cdn. Found here: https://cdn.jsdelivr.net/npm/@microsoft/signalr@6.0.2/dist/browser/signalr.js
I am also getting the exact same error and issue as reported by @afranz33 . I am using WebOptimizer which uses NUglify and had to remove signalr from the bundle as a work around
I need a minimum repo to look at this please, not a whole file
@trullock here is a example of the minimum to reproduce issue. Similar to other test cases you have Example Test
using System;
using System.Net;
using NUglify;
namespace NUglify_Issue_298
{
class Program
{
static void Main(string[] args)
{
try
{
WebClient client = new WebClient();
string jqueryText = client.DownloadString("https://cdnjs.cloudflare.com/ajax/libs/microsoft-signalr/6.0.1/signalr.js");
UglifyResult result = Uglify.Js(jqueryText);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}
}
}
}
Error: Object reference not set to an instance of an object. StackTrace
at NUglify.JavaScript.Visitors.NewParensVisitor.Visit(MemberExpression node)
at NUglify.JavaScript.Syntax.MemberExpression.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.NewParensVisitor.Visit(MemberExpression node)
at NUglify.JavaScript.Syntax.MemberExpression.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(CallExpression node)
at NUglify.JavaScript.Syntax.CallExpression.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.AcceptNodeWithParens(AstNode node, Boolean needsParens)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(VariableDeclaration node)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(LexicalDeclaration node)
at NUglify.JavaScript.Syntax.LexicalDeclaration.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node)
at NUglify.JavaScript.Visitors.OutputVisitor.OutputFunctionArgsAndBody(FunctionObject node)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(FunctionObject node)
at NUglify.JavaScript.Syntax.FunctionObject.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(ClassNode node)
at NUglify.JavaScript.Syntax.ClassNode.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node)
at NUglify.JavaScript.Visitors.OutputVisitor.OutputFunctionArgsAndBody(FunctionObject node)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(FunctionObject node)
at NUglify.JavaScript.Syntax.FunctionObject.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(GroupingOperator node)
at NUglify.JavaScript.Syntax.GroupingOperator.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.AcceptNodeWithParens(AstNode node, Boolean needsParens)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(CallExpression node)
at NUglify.JavaScript.Syntax.CallExpression.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(ReturnStatement node)
at NUglify.JavaScript.Syntax.ReturnStatement.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node)
at NUglify.JavaScript.Visitors.OutputVisitor.OutputFunctionArgsAndBody(FunctionObject node)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(FunctionObject node)
at NUglify.JavaScript.Syntax.FunctionObject.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.AcceptNodeWithParens(AstNode node, Boolean needsParens)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BinaryExpression node)
at NUglify.JavaScript.Syntax.BinaryExpression.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node)
at NUglify.JavaScript.Syntax.BlockStatement.Accept(IVisitor visitor)
at NUglify.JavaScript.Visitors.OutputVisitor.Apply(TextWriter writer, AstNode node, CodeSettings settings)
at NUglify.Uglify.Js(String source, String fileName, CodeSettings codeSettings)
at NUglify_Issue_298.Program.Main(String[] args) in D:\personal\git\NUglify-Issue-298\NUglify-Issue-298\Program.cs:line 15
I need the minimum amount of javascript that causes this.
Whilst keeping syntatic (but not functional) correctness, remove blocks of signalr.js until your exception goes away. That last bit you deleted contains the quirk. Put that block back and remove the rest. Repeat until you have the minimum amount of JS that causes this error and I can help you
@trullock i have narrowed it down to the following code that is giving the error. mainly the new.target
class n extends Error {
constructor() {
const s = new.target.prototype;
}
}
I hope this helps.
here is the full code of the class for more context used by Microsoft's SignalR code
class n extends Error {
constructor(t, e) {
const s = new.target.prototype;
super(`${t}: Status code '${e}'`),
(this.statusCode = e),
(this.__proto__ = s);
}
}
TIL that is a syntax!
Yeah thats probably broken
Thanks for the repro!
fixed in 1.19.2
When I try using this pipeline code pipeline.AddJavaScriptBundle and adding the signalr.js (latest dist) file it fails with error stack of below. I tried bundling it by itself, adding it with others etc and get the same issue.
message: Exception thrown at 0x00007FFD7C144F69 (KernelBase.dll) in w3wp.exe: 0xC0000005: Access violation reading location 0x0000000000000000.
Stack System.NullReferenceException: Object reference not set to an instance of an object. at NUglify.JavaScript.Visitors.NewParensVisitor.Visit(MemberExpression node) at NUglify.JavaScript.Syntax.MemberExpression.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.NewParensVisitor.Visit(MemberExpression node) at NUglify.JavaScript.Syntax.MemberExpression.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(CallExpression node) at NUglify.JavaScript.Syntax.CallExpression.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.AcceptNodeWithParens(AstNode node, Boolean needsParens) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(VariableDeclaration node) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(LexicalDeclaration node) at NUglify.JavaScript.Syntax.LexicalDeclaration.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node) at NUglify.JavaScript.Visitors.OutputVisitor.OutputFunctionArgsAndBody(FunctionObject node) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(FunctionObject node) at NUglify.JavaScript.Syntax.FunctionObject.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(ClassNode node) at NUglify.JavaScript.Syntax.ClassNode.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node) at NUglify.JavaScript.Visitors.OutputVisitor.OutputFunctionArgsAndBody(FunctionObject node) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(FunctionObject node) at NUglify.JavaScript.Syntax.FunctionObject.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(GroupingOperator node) at NUglify.JavaScript.Syntax.GroupingOperator.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.AcceptNodeWithParens(AstNode node, Boolean needsParens) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(CallExpression node) at NUglify.JavaScript.Syntax.CallExpression.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(ReturnStatement node) at NUglify.JavaScript.Syntax.ReturnStatement.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node) at NUglify.JavaScript.Visitors.OutputVisitor.OutputFunctionArgsAndBody(FunctionObject node) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(FunctionObject node) at NUglify.JavaScript.Syntax.FunctionObject.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.AcceptNodeWithParens(AstNode node, Boolean needsParens) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BinaryExpression node) at NUglify.JavaScript.Syntax.BinaryExpression.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(AstNodeList node) at NUglify.JavaScript.Syntax.AstNodeList.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BinaryExpression node) at NUglify.JavaScript.Syntax.BinaryExpression.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Visit(BlockStatement node) at NUglify.JavaScript.Syntax.BlockStatement.Accept(IVisitor visitor) at NUglify.JavaScript.Visitors.OutputVisitor.Apply(TextWriter writer, AstNode node, CodeSettings settings) at NUglify.Uglify.Js(String source, String fileName, CodeSettings codeSettings) at WebOptimizer.JavaScriptMinifier.ExecuteAsync(IAssetContext config) at WebOptimizer.Asset.ExecuteAsync(HttpContext context, IWebOptimizerOptions options) at WebOptimizer.AssetBuilder.BuildAsync(IAsset asset, HttpContext context, IWebOptimizerOptions options) at WebOptimizer.AssetMiddleware.HandleAssetAsync(HttpContext context, IAsset asset, WebOptimizerOptions options) at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)