Error content and map of this source is not available only size is supported

My project was working fine. When I upgraded to Webpack 5 this issue occurred. I searched online, but all the discussions seem to be from a previous version and I even tried the workarounds specifi...

I’m using Webpack module federation in angular for developing micro frontend architecture.

Usually lot of dependencies or version mismatch is going to happen.
Ref: Error Screen

Just do:

npm install

Sometimes if you added a new node packages then there is chances of getting these type of errors. So that, to update the packages which are most likely to be dependent on the new installed packages run — npm install.

It worked for me.

Again i faced same problem then i used the below command

npm install source-map-support

Also please check the port number which you are using for the project. Try to change the port numbers to a different port numbers which are unused and safer.
Eg: If you are using the port http://localhost:2000/ then change it to different one in your angular.json file

"options": {
                        "port": 5000,
                        "publicHost": "http://localhost:5000",
                        "extraWebpackConfig": "projects/core/webpack.config.js"
                    }

and also if you customized the commands for each micro frontend apps then change the port numbers in package.json file also

    "ng": "ng",
    "start": "npm run start:core",
    "start:core": "ng serve core  -o --port 5000",
    "start:dashboard": "ng serve dashboard -o --port 3000"
    }

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

andreialecu opened this issue

Nov 26, 2021

· 35 comments

Comments

@andreialecu

Bug report

I’m running into Error: Content and Map of this Source is not available (only size() is supported) with Angular.

This seems to have been reported in various other places recently:
https://stackoverflow.com/questions/70066980/angular-12-content-and-map-of-this-source-is-not-available-only-size-is-suppo

What is the current behavior?

.../node_modules/webpack-sources/lib/SizeOnlySource.js:16
                return new Error(
                       ^

Error: Content and Map of this Source is not available (only size() is supported)
    at SizeOnlySource._error (.../node_modules/webpack-sources/lib/SizeOnlySource.js:16:10)
    at SizeOnlySource.buffer (.../node_modules/webpack-sources/lib/SizeOnlySource.js:30:14)
    at _isSourceEqual (.../node_modules/webpack/lib/util/source.js:21:51)
    at isSourceEqual (.../node_modules/webpack/lib/util/source.js:43:17)
    at Compilation.emitAsset (.../node_modules/webpack/lib/Compilation.js:4155:9)
    at .../node_modules/webpack/lib/Compiler.js:546:28
    at .../node_modules/webpack/lib/Compiler.js:1127:17
    at eval (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
The terminal process "zsh '-c', 'yarn run start'" terminated with exit code: 1.

If the current behavior is a bug, please provide the steps to reproduce.

I don’t have a clear reproduction, however I was able to add some logs in emitAsset here, which is part of the stack trace:

if (!isSourceEqual(this.assets[file], source)) {
this.errors.push(
new WebpackError(
`Conflict: Multiple assets emit different content to the same filename ${file}`
)
);

I added:

	emitAsset(file, source, assetInfo = {}) {
		if (this.assets[file]) {
			try {
				!isSourceEqual(this.assets[file], source);
			} catch (err) {
				console.error(file, this.assets[file], source);
				throw err;
			}

The output before the crash is:

fontawesome-webfont.eot SizeOnlySource { _size: 165742 } RawSource {
  _valueIsBuffer: true,
  _value: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsBuffer: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsString: undefined
}

It always seems to crash on the same eot file. Notice that this.assets[file] for this file is a SizeOnlySource.

What is the expected behavior?

No crash.

Other relevant information:
webpack version: 5.60.0
Node.js version: 16.13.0
Operating System: MacOS 11.4
Additional tools: Angular 13.0.1

@alexander-akait

Expected, something try to get content there is not content, replaced after writing by webpack, please wait the answer of angular team, we can’t fix it on our side, sorry

@andreialecu

@andreialecu

@alexander-akait after some discussion with an Angular team member in the issue mentioned above, it seems that they don’t think this problem is on their side.

The stacktrace only mentions webpack from top to bottom, and I noticed that if I delete the webpack cache the problem goes away.

Would you mind taking a look at the discussion there? Thanks!

@alexander-akait

@andreialecu

Unfortunately no, this is a huge project and it seems to be occurring very randomly as also noted in: angular/angular-cli#22237 (comment) where simply re-cloning got rid of the error.

The key part is probably figuring out why SizeOnlySource is being compared to a RawSource and how it ends up in that state. I’m hoping there’s an easy way to simply audit the code based on that information.

@alexander-akait

I am afraid without more information, nobody can help with the problem, do you have enabled cache, can you try to disable, how often it happens? Is it watch/dev server/single build?

@andreialecu

Currently it’s not happening in my project any more.

But it clears up after removing the cache. It also clears up randomly after messing with package.json dependencies.

However it also randomly comes back. I’ve had this come and go several times over the last few days.

Once it starts happening again I’ll archive the project so I have a reproduction.

@alexander-akait

@sokra

This kind of error usually happens when trying to emit assets after the compiler has already written the assets to the output directory. (After writing webpack replaces the assets with SizeOnlySources, which drops the content for memory reasons)

From the stack trace it looks like a child compiler finishes very later and tries to emits its assets to the parent compiler.

So I think the problem is that somewhere a child compiler is started, but not correctly awaited for completion. That makes it timing dependent when the assets are emitted to the parent compiler, which could randomly cause this error.

@andreialecu

@sokra from my observations I think your assumptions are correct.

When this was occurring, the process was as follows:

  • Angular starts an initial compilation. This takes a while and «Compilation successful» is printed.
  • Angular then automatically starts a second compilation which usually takes a second or so. Probably because everything is already cached. At this point it prints «Compilation successful» again. And then the error comes up a split second later. You can see this in my screenshot of the error.

I’m not sure what the reason for the double compilation is. Might be something internal to Angular.

@andreialecu

@alexander-akait

Angular then automatically starts a second compilation which usually takes a second or so

I think this shouldn’t be happening, do you have custom plugins?

@alexander-akait

@andreialecu Anyway I strong recommend do not close angular/angular-cli#22237, I’m almost sure that the problem is on their side, no one except angular users faced with it (this is a pretty clear hint)

@sokra

From the angular issue it sounds a bit like that might be related to css build. A font file could be referenced by css child compiler and main compiler. Is angular using mini-css?

@alan-agius4

@sokra, yeah we are using mini-css.

@alexander-akait

Will be great to see more items in stack trace…

@andreialecu

@alexander-akait for some reason that’s the entire stack trace (the part after ✔ Compiled successfully. is my own logging) :

✔ Compiled successfully.
fontawesome-webfont.eot SizeOnlySource { _size: 165742 } RawSource {
  _valueIsBuffer: true,
  _value: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsBuffer: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsString: undefined
}
.../node_modules/webpack-sources/lib/SizeOnlySource.js:16
                return new Error(
                       ^

Error: Content and Map of this Source is not available (only size() is supported)
    at SizeOnlySource._error (.../node_modules/webpack-sources/lib/SizeOnlySource.js:16:10)
    at SizeOnlySource.buffer (.../node_modules/webpack-sources/lib/SizeOnlySource.js:30:14)
    at _isSourceEqual (.../node_modules/webpack/lib/util/source.js:21:51)
    at isSourceEqual (.../node_modules/webpack/lib/util/source.js:43:17)
    at Compilation.emitAsset (.../node_modules/webpack/lib/Compilation.js:4156:6)
    at .../node_modules/webpack/lib/Compiler.js:546:28
    at .../node_modules/webpack/lib/Compiler.js:1127:17
    at eval (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
The terminal process "zsh '-c', 'yarn run start'" terminated with exit code: 1.

@andreialecu

I’m not sure if this is in any way helpful, but once it starts occurring it seems to always be the same file. The only place that file is referenced is through the font-awesome npm package:

https://unpkg.com/font-awesome@4.7.0/scss/_path.scss

Notice how it’s listed twice, once with a query string. I took a look through webpack sources and I notice that there’s some logic related to query strings:

const queryStringIdx = targetFile.indexOf(«?»);
if (queryStringIdx >= 0) {
targetFile = targetFile.substr(0, queryStringIdx);
// We may remove the hash, which is in the query string
// So we recheck if the file is immutable
// This doesn’t cover all cases, but immutable is only a performance optimization anyway
immutable =
immutable &&
(includesHash(targetFile, info.contenthash) ||
includesHash(targetFile, info.chunkhash) ||
includesHash(targetFile, info.modulehash) ||
includesHash(targetFile, info.fullhash));
}

immutable seem to then be used to consider whether to turn an asset into a SizeOnlySource later below.

Running a full angular build (non watch-mode) works. It works so well actually that it seems to clear up the initial error so now I can no longer reproduce it, again. It does pop up randomly though, so I’m hoping next time I can troubleshoot it further.

@alexander-akait

Sounds like a cache problem… Do you enable cache?

@andreialecu

Yes, the cache is enabled, I mentioned it earlier:

The stacktrace only mentions webpack from top to bottom, and I noticed that if I delete the webpack cache the problem goes away.

@alexander-akait

@alan-agius4

Following a convo on discord with @andreialecu, it turns out that this stylesheet is actually referenced in a component and therefore it doesn’t use mini-css. I therefore suspect that this might be an issue with our plugin.

@alan-agius4

While digging into this, I stumbled upon the double incremental re-builds issue when the cache is restored. There appears to be an issue with Webpack, when loaders are not hoisted to the top level node_modules and during watch mode.

More info: #14911

@alexander-akait

@alan-agius4

No, see steps in #14911 (comment). Note, this is not related to the only size() is supported issue. Just wanted to mention it here, since some people mentioned the double rebuild problem here.

@alan-agius4

Regarding the original issue, what I think is happening is that we are storing the assets from child compilers in a Map.

for (const { info, name, source } of childCompilation.getAssets()) {
   this.assetCache.set(cacheKey, { info, name, source });
}

Later on during an incremental build, we are re-emitting these assets from cache.

for (const [, { name, source, info }] of this.assetCache) {
   this._parentCompilation.emitAsset(name, source, info);
}

I suspect that in some cases, the source is mutated to SizeOnlySources. My 2 cents would be that in the cache we store source as string or buffer instead of the source Instance.

Ie:

this.assetCache.set(cacheKey, { info, name, source: source.source() });

And when we re-emit, we create a new RawSource everytime.

this._parentCompilation.emitAsset(name, new sources.RawSource(source), info);

@alexander-akait

hm, I think you should not store string or buffer, only sources have cache logic, so better to store them and avoid creating sources.RawSource, because it is also bad for performance

@alan-agius4

Actually, I was wrong, at first seeing the logic here, the asset is not mutated since we are creating a new object each time, so back to square one.

@alexander-akait

Logic for child compilations is the same as for common compilations, and yes source can be SizeOnlySource if child compilation is cacheable, you can mark modules are not cachable to avoid this problem, but better to store source instead string or buffer, also it will be faster, maybe if you provide example of code I can help

@alan-agius4

@andreialecu

Can you try to increase stack trace using --stack-trace-limit (nodejs.org/api/cli.html)?

I keep getting this error on and off, and I tried adding Error.stackTraceLimit = Infinity; and longjohn. I’m not sure if either are supposed to work any more, but they didn’t change anything.

I’m on Node 16.13.0, and this is an async unhandled promise error, which quits the process. There’s a similar stack trace shown here: nodejs/node#11865 (comment)

I’m not sure why I can’t get a longer stack trace.

In the mean time I’ve been trying to debug it further and I noticed that the double compilation issue in my case is caused by a missing/leftover file in angular.json‘s assets field.

It appears that a recompilation is triggered with changedFiles just containing the path to that missing file. This is possibly an Angular issue. Not sure if #14911 (comment) is related or not. @alan-agius4 might be able to clarify (I also left additional details on Discord)

Other findings are that if I try to copy the entire project somewhere else, the error will not occur. I even tried to use rsync to preserve file access times, without success. After inspecting the Angular cache files, it appears that full FS paths are hard-coded/baked into the cache. This may trigger an invalidation when the compilation is being ran from elsewhere, and it clears the error.

I’ve also been trying to add or remove various things to angular’s webpack plugin without success. Once the error happens it keeps happening until the cache is invalidated.

@andreialecu

To add to the above, I thought the error was triggered by the second compilation because it would only ever occur after it — however after removing the leftover file it now compiles just once.

The error still occurs, it just happens a second or so after ✔ Compiled successfully. is printed by Angular.

Here’s a recording. (there are some weird console.logs showing as well, from my debugging)

Screen.Recording.2021-12-08.at.11.31.20.mov

@alan-agius4

@andreialecu, is it a possibility to either share your project (privately) or schedule a call so that we can debug this together?

@andreialecu

@alan-agius4

🐞 Bug report

Command (mark with an x)

  • build
  • serve

Is this a regression?

Yes, didn’t see this with Angular 12.

Description

I’m running into Error: Content and Map of this Source is not available (only size() is supported) with Angular.

This seems to have been reported in various other places recently:
stackoverflow.com/questions/70066980/angular-12-content-and-map-of-this-source-is-not-available-only-size-is-suppo

I’m not sure if this is an Angular or Webpack issue, I also crossposted this to webpack: webpack/webpack#14840

🔬 Minimal Reproduction

I don’t have a clear reproduction, however I was able to add some logs in emitAsset here, which is part of the stack trace:
https://github.com/webpack/webpack/blob/14582fc41504595b04f01561ea19d27391d6b9ac/lib/Compilation.js#L4171-L4176

I added:

	emitAsset(file, source, assetInfo = {}) {
		if (this.assets[file]) {
			try {
				!isSourceEqual(this.assets[file], source);
			} catch (err) {
				console.error(file, this.assets[file], source);
				throw err;
			}

The output before the crash is:

fontawesome-webfont.eot SizeOnlySource { _size: 165742 } RawSource {
  _valueIsBuffer: true,
  _value: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsBuffer: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsString: undefined
}

It always seems to crash on the same eot file. Notice that this.assets[file] for this file is a SizeOnlySource.

🔥 Exception or Error

.../node_modules/webpack-sources/lib/SizeOnlySource.js:16
                return new Error(
                       ^

Error: Content and Map of this Source is not available (only size() is supported)
    at SizeOnlySource._error (.../node_modules/webpack-sources/lib/SizeOnlySource.js:16:10)
    at SizeOnlySource.buffer (.../node_modules/webpack-sources/lib/SizeOnlySource.js:30:14)
    at _isSourceEqual (.../node_modules/webpack/lib/util/source.js:21:51)
    at isSourceEqual (.../node_modules/webpack/lib/util/source.js:43:17)
    at Compilation.emitAsset (.../node_modules/webpack/lib/Compilation.js:4155:9)
    at .../node_modules/webpack/lib/Compiler.js:546:28
    at .../node_modules/webpack/lib/Compiler.js:1127:17
    at eval (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
The terminal process "zsh '-c', 'yarn run start'" terminated with exit code: 1.

🌍 Your Environment

Angular CLI: 13.0.2
Node: 16.13.0
Package Manager: yarn 3.1.0
OS: darwin arm64

Angular: 13.0.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.2
@angular-devkit/build-angular   13.0.2
@angular-devkit/core            13.0.2
@angular-devkit/schematics      13.0.2
@angular/cli                    13.0.2
@angular/flex-layout            12.0.0-beta.35
@schematics/angular             13.0.2
rxjs                            7.4.0
typescript                      4.4.4```

**Anything else relevant?**

<!-- ✍️Is this a browser specific issue? If so, please specify the browser and version. -->

<!-- ✍️Do any of these matter: operating system, IDE, package manager, HTTP server, ...? If so, please mention it below. -->

Issue

I have been working with angular project and have angular version is 13 and node is 16 versions.

When i use command npm run start its throwing an error(compilation error). Pasted the error below

Error: Content and Map of this Source is not available (only size() is supported)
    at SizeOnlySource._error (C:Usersprojnode_moduleswebpack-sourceslibSizeOnlySource.js:16:10)
    at SizeOnlySource.buffer (C:Usersprojnode_moduleswebpack-sourceslibSizeOnlySource.js:30:14)
    at _isSourceEqual (C:Usersprojnode_moduleswebpacklibutilsource.js:21:51)
    at isSourceEqual (C:Usersprojnode_moduleswebpacklibutilsource.js:43:17)
    at Compilation.emitAsset (C:Usersprojnode_moduleswebpacklibCompilation.js:4171:9)
    at C:Usersprojnode_moduleswebpacklibCompiler.js:548:28
    at C:Usersprojnode_moduleswebpacklibCompiler.js:1129:17
    at eval (eval at create (C:Usersprojnode_modulestapablelibHookCodeFactory.js:33:10), <anonymous>:13:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

I have tried these solution.None of them are permanent solutions.

  1. Remove .angular folder from project and run npm install followed by npm run start command

  2. set sourceMap flag as false

  3. Tried to install sourceMap using npm install command

webpack version

enter image description here

These solutions are get it from the other stackoverfolw similar questions.

Anyone know why this error comes.

Do we have a permanent solution for this issue.
Expecting a better solution

Solution

From the answer found here. The short and sweet of it is that the .angular folder found in your project directory sometimes gets corrupted and the best way to fix it is to delete the folder entirely. Then run npm install to recreate a bug free version, and then run ng serve (or npm run start if that’s what you’re used to).

Answered By — WhoIsCarlo

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

def initAlgorithm(self, config=None):
    self.addParameter(QgsProcessingParameterFile('dailyshpfolder', 'Please Input Your Daily SHP folder', behavior=QgsProcessingParameterFile.Folder, fileFilter='All files (*.*)', defaultValue=None))

def __init__(self):
    super().__init__()
    
def name(self):
    return 'Daily to Master'

def tr(self, text):
    return QCoreApplication.translate("Daily to Master", text)
    
def displayName(self):
    return self.tr("Move daily SHP into Master layers -HA- Tech Services")

def helpUrl(self):
    return "https://qgis.org"
    

def createInstance(self):
    return DailyToMaster()

def processAlgorithm(self, parameters, context, model_feedback):
    # Use a multi-step feedback, so that individual child algorithm progress reports are adjusted for the
    # overall progress through the model
    feedback = QgsProcessingMultiStepFeedback(29, model_feedback)
    results = {}
    outputs = {}

    # Add SHP from daily SHP folder
    
    alg_params = {
        'INPUT': parameters['dailyshpfolder']
    }
    outputs['AddShpFromDailyShpFolder'] = processing.run('script:Import_folder', alg_params, context=context, feedback=feedback, is_child_algorithm=True)

    feedback.setCurrentStep(1)
    if feedback.isCanceled():
        return {}
    
    
    # Append Natural
    HAnatural = QgsProject.instance().mapLayersByName('HA_Natural.shp')
    natural = QgsProject.instance().mapLayersByName('Natural')
    if  HAnatural and natural:
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Natural.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Natural','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendNatural'] = processing.run('etl_load:appendfeaturestolayer',alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    if not HAnatural or not natural:
        print('No new Natural feature')
        pass
    feedback.setCurrentStep(2)
    if feedback.isCanceled():
        return {}

    # Append Field Drain
    HAfielddrain = QgsProject.instance().mapLayersByName('HA_Field_Drain.shp')
    fielddrain = QgsProject.instance().mapLayersByName('Field Drain')
    if  HAfielddrain  and fielddrain :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Field_Drain.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Field Drain','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendFieldDrain'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAfielddrain  or not fielddrain :
        print('No new Field Drain feature')
        pass
    
    feedback.setCurrentStep(3)
    if feedback.isCanceled():
        return {}

    # Append Points
    HApoints = QgsProject.instance().mapLayersByName('HA_Points.shp')
    points = QgsProject.instance().mapLayersByName('Points')
    if HApoints  and points :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('Points.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Points','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendPoints'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HApoints  or not points :
        print('No new Points feature')
        pass

    feedback.setCurrentStep(4)
    if feedback.isCanceled():
        return {}

    # Append Modern
    HAmodern = QgsProject.instance().mapLayersByName('HA_Modern.shp')
    modern = QgsProject.instance().mapLayersByName('Modern')
    if HAmodern and modern :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Modern.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Modern','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendModern'] = processing.run('etl_load:appendfeaturestolayer', alg_params,context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAmodern or not modern :
        print('No new Modern feature')
        pass
        
    feedback.setCurrentStep(5)
    if feedback.isCanceled():
        return {}

    # Append GR Point
    HAGRpoint = QgsProject.instance().mapLayersByName('HA_GR_Point.shp')
    GRpoint = QgsProject.instance().mapLayersByName('GR Point')
    if HAGRpoint and GRpoint :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_GR_Point.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('GR Point','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendGrPoint'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAGRpoint or not GRpoint :
        print('No new GR Point feature')
        pass
        
    feedback.setCurrentStep(6)
    if feedback.isCanceled():
        return {}

    # Append Test Pit
    HAtestpit = QgsProject.instance().mapLayersByName('HA_Test_Pit.shp')
    testpit = QgsProject.instance().mapLayersByName('Test Pit')
    if HAtestpit and testpit :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Test_Pit.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Test Pit','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendTestPit'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAtestpit or not testpit :
        print('No new Test Pit feature')
        pass

    feedback.setCurrentStep(7)
    if feedback.isCanceled():
        return {}

    # Append Excavated
    HAexcavated = QgsProject.instance().mapLayersByName('HA_Excavated.shp')
    excavated = QgsProject.instance().mapLayersByName('Excavated')
    if HAexcavated and excavated :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Excavated.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Excavated','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendExcavated'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAexcavated or not excavated :
        print('No new Excavated feature')
        pass
        
    feedback.setCurrentStep(8)
    if feedback.isCanceled():
        return {}

    # Append Structure
    HAstructure = QgsProject.instance().mapLayersByName('HA_Structure.shp')
    structure = QgsProject.instance().mapLayersByName('Structure')
    if HAstructure and structure :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Structure.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Structure','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendStructure'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAstructure or not structure :
        print('No new Structure feature')
        pass

    feedback.setCurrentStep(9)
    if feedback.isCanceled():
        return {}

    # Append Sample
    HAsample = QgsProject.instance().mapLayersByName('HA_Sample.shp')
    sample = QgsProject.instance().mapLayersByName('Sample')
    if HAsample and sample :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Sample.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Sample','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendSample'] = processing.run('etl_load:appendfeaturestolayer', alg_params,context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAsample or not sample :
        print('No new Sample feature')
        pass

    feedback.setCurrentStep(10)
    if feedback.isCanceled():
        return {}

    

    # Append Inhumation
    HAinhum = QgsProject.instance().mapLayersByName('HA_Inhumation.shp')
    inhum = QgsProject.instance().mapLayersByName('Inhumation')
    if  HAinhum and inhum :
        alg_params = {
            'ACTION_ON_DUPLICATE': 0,  # Just APPEND all features, no matter of duplicates
            'SOURCE_FIELD': '',
            'SOURCE_LAYER': QgsExpression("layer_property('HA_Inhumation.shp','name')").evaluate(),
            'TARGET_FIELD': '',
            'TARGET_LAYER': QgsExpression("layer_property('Inhumation','name')").evaluate()
        }
        context = dataobjects.createContext()
        context.setInvalidGeometryCheck(QgsFeatureRequest.GeometryNoCheck)
        outputs['AppendInhumation'] = processing.run('etl_load:appendfeaturestolayer', alg_params, context=context, feedback=feedback, is_child_algorithm=True)
    elif not HAinhum or not inhum :
        print('No new Inhumation feature')
        pass
    return results

Я работаю с угловым проектом, и угловая версия — 13, а узел — 16 версий.

Когда я использую команду npm run start, она выдает ошибку (ошибка компиляции). Вставил ошибку ниже

Error: Content and Map of this Source is not available (only size() is supported)
    at SizeOnlySource._error (C:Usersprojnode_moduleswebpack-sourceslibSizeOnlySource.js:16:10)
    at SizeOnlySource.buffer (C:Usersprojnode_moduleswebpack-sourceslibSizeOnlySource.js:30:14)
    at _isSourceEqual (C:Usersprojnode_moduleswebpacklibutilsource.js:21:51)
    at isSourceEqual (C:Usersprojnode_moduleswebpacklibutilsource.js:43:17)
    at Compilation.emitAsset (C:Usersprojnode_moduleswebpacklibCompilation.js:4171:9)
    at C:Usersprojnode_moduleswebpacklibCompiler.js:548:28
    at C:Usersprojnode_moduleswebpacklibCompiler.js:1129:17
    at eval (eval at create (C:Usersprojnode_modulestapablelibHookCodeFactory.js:33:10), <anonymous>:13:1)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

Я пробовал эти решения. Ни одно из них не является постоянным решением.

  1. Удалите папку .angular из проекта и запустите npm install, а затем команду npm run start.

  2. установить флаг sourceMap как false

  3. Попытка установить sourceMap с помощью команды npm install

версия веб-пакета

enter image description here

Эти решения получены из других похожих вопросов stackoverfolw.

Кто-нибудь знает, почему появляется эта ошибка.

Есть ли у нас постоянное решение этой проблемы. Ожидание лучшего решения

2 ответа

Лучший ответ

Из ответа, найденного здесь. Коротко и приятно то, что папка .angular, найденная в каталоге вашего проекта, иногда повреждается, и лучший способ исправить это — полностью удалить папку. Затем запустите npm install, чтобы воссоздать версию без ошибок, а затем запустите ng serve (или npm run start, если вы к этому привыкли).


4

WhoIsCarlo
30 Июл 2022 в 10:28

Удалите .angular и .node_modules. Чем запустить npm install, после запуска npm


0

Fernando Dias Motta
12 Сен 2022 в 22:52

🐞 Bug report

Command (mark with an x)

  • build
  • serve

Is this a regression?

Yes, didn’t see this with Angular 12.

Description

I’m running into Error: Content and Map of this Source is not available (only size() is supported) with Angular.

This seems to have been reported in various other places recently:
stackoverflow.com/questions/70066980/angular-12-content-and-map-of-this-source-is-not-available-only-size-is-suppo

I’m not sure if this is an Angular or Webpack issue, I also crossposted this to webpack: webpack/webpack#14840

🔬 Minimal Reproduction

I don’t have a clear reproduction, however I was able to add some logs in emitAsset here, which is part of the stack trace:
https://github.com/webpack/webpack/blob/14582fc41504595b04f01561ea19d27391d6b9ac/lib/Compilation.js#L4171-L4176

I added:

	emitAsset(file, source, assetInfo = {}) {
		if (this.assets[file]) {
			try {
				!isSourceEqual(this.assets[file], source);
			} catch (err) {
				console.error(file, this.assets[file], source);
				throw err;
			}

The output before the crash is:

fontawesome-webfont.eot SizeOnlySource { _size: 165742 } RawSource {
  _valueIsBuffer: true,
  _value: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsBuffer: <Buffer 6e 87 02 00 ac 86 02 00 01 00 02 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 90 01 00 00 00 00 4c 50 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ... 165692 more bytes>,
  _valueAsString: undefined
}

It always seems to crash on the same eot file. Notice that this.assets[file] for this file is a SizeOnlySource.

🔥 Exception or Error

.../node_modules/webpack-sources/lib/SizeOnlySource.js:16
                return new Error(
                       ^

Error: Content and Map of this Source is not available (only size() is supported)
    at SizeOnlySource._error (.../node_modules/webpack-sources/lib/SizeOnlySource.js:16:10)
    at SizeOnlySource.buffer (.../node_modules/webpack-sources/lib/SizeOnlySource.js:30:14)
    at _isSourceEqual (.../node_modules/webpack/lib/util/source.js:21:51)
    at isSourceEqual (.../node_modules/webpack/lib/util/source.js:43:17)
    at Compilation.emitAsset (.../node_modules/webpack/lib/Compilation.js:4155:9)
    at .../node_modules/webpack/lib/Compiler.js:546:28
    at .../node_modules/webpack/lib/Compiler.js:1127:17
    at eval (eval at create (.../node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:13:1)
The terminal process "zsh '-c', 'yarn run start'" terminated with exit code: 1.

🌍 Your Environment

Angular CLI: 13.0.2
Node: 16.13.0
Package Manager: yarn 3.1.0
OS: darwin arm64

Angular: 13.0.1
... animations, cdk, common, compiler, compiler-cli, core, forms
... language-service, material, platform-browser
... platform-browser-dynamic, router, service-worker

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1300.2
@angular-devkit/build-angular   13.0.2
@angular-devkit/core            13.0.2
@angular-devkit/schematics      13.0.2
@angular/cli                    13.0.2
@angular/flex-layout            12.0.0-beta.35
@schematics/angular             13.0.2
rxjs                            7.4.0
typescript                      4.4.4```

**Anything else relevant?**

<!-- ✍️Is this a browser specific issue? If so, please specify the browser and version. -->

<!-- ✍️Do any of these matter: operating system, IDE, package manager, HTTP server, ...? If so, please mention it below. -->
Issue Title Created Date Comment Count Updated Date
Creating Customer attribute 1 2021-03-02 2023-01-11
`repl_expect` unable to find location of error 1 2022-12-22 2023-02-01
— Filesize:1495026 [weak]
E: Unable to fetch some archives, maybe run apt-get update or try with —fix-missing?
1 2021-06-12 2023-02-05
Random crashes on start-up 4 2022-12-22 2023-02-08
SFTP : Ability to unzip an archive 6 2023-01-07 2023-02-03
Provide Path for `flowdb` Folder Containing Emulator State 2 2022-10-20 2023-01-11
[Feature] — Add logs from transaction and scripts 0 2022-10-18 2023-01-11
ReadMe: Deprecated emulator start command 0 2022-10-12 2023-02-04
Why can’t the nApplyForBox function be found in the contract ? 3 2022-03-31 2023-01-04
Object Demo doesn’t show textures 3 2021-04-03 2023-01-28
Document new CLI support for multiple invariants or temporal operators 1 2022-08-29 2023-02-07
Shai: Support supplying text input source from config input (so we can then parse it out of RPC json data) 1 2022-08-30 2022-09-24
Error: received invalid response to GSSAPI negotiation: 2 2021-07-01 2023-02-06
windows starts 1024×768 resolution even SCREEN_RESOLUTION changed to 1920x1080x24 8 2019-11-24 2023-01-26
wrong size for the recovered integer array 5 2019-11-08 2023-01-26
Added Data Zoom 0 2021-11-17 2022-01-12
os15 cannot run 3 2021-09-30 2022-01-19
[SingleServerSupport] Migrate C# & HTML rename to Razor Language Server 0 2022-07-27 2022-12-27
Error message hints displayed weirdly if there is also a source context 1 2022-02-21 2023-02-05
import problem — incompatibility with numpy 2 2021-03-22 2022-10-26
Adjust largest symbol size in mf_map(…, type = «prop*», val_max = max) 0 2021-03-11 2023-01-16
Using Sentiment Tools — Unexpected Identifier Line 73 1 2020-09-14 2023-01-19
Request: class validator, promises response errors 10 2021-03-19 2022-12-23
开发环境 NODE_ENV=development 启动时,自动生成元数据同步相关环境变量 1 2022-07-18 2022-11-17
Research BigQuery destination connector 1 2022-02-04 2023-01-28
Latest Steam-Client beta won’t start with mesa-git 35 2021-11-03 2023-02-04
Add `n_elements_` attribute to masker objects 4 2022-06-30 2023-02-05
Add a few repos to instances by default 7 2022-10-14 2023-02-05
`resolve.extensions` is not work on pre-build stage 4 2022-01-13 2023-01-16
[Feature Request] Initiate the playground form a workspace config file 0 2021-06-30 2023-01-25
What does «ZAP not enabled» mean and where is anything else ZAP-related 1 2022-01-31 2023-02-02
f_update_clamav_db failing because of daily.cvd version 2 2021-01-06 2023-01-29
Slim down our react-resize dependency (or replace it) 0 2022-06-30 2022-12-05
Philips 324131092621 doesn’t report *_hold states 1 2021-10-02 2023-01-09
Request to document flamegraph interpretion 2 2021-10-28 2023-02-04
Access to an undefined property 3 2022-01-20 2023-01-28
Link to the contributing docs from the README 1 2022-01-16 2023-02-04
Display full hierarchy of chosen collection (during submission/workflow) 2 2021-09-30 2022-10-26
loads of errors when hash file not found for my joomla version 0 2021-02-17 2023-02-05
Hashing class not found 0 2022-11-16 2023-02-02
Arduino & ESP32 Download Tool 3 2021-10-22 2022-12-20
[fastpages] Automated Upgrade 1 2021-10-02 2023-01-27
[fastpages] Automated Upgrade 1 2021-09-27 2023-01-09
Set new file default tabstop? 1 2022-07-26 2023-02-03
Bump lodash from 4.17.15 to 4.17.19 0 2020-07-18 2022-12-22
Context.startForegroundService() did not then call Service.startForeground() 8 2022-03-09 2022-12-20
Demo script fails with ImportError: cannot import name ‘metanet_pb2’ from ‘caffe2.proto’ 15 2021-11-09 2023-02-08
Link Label, Curved Lines & Self Links — Not Playing Nicely? 6 2021-03-27 2022-12-29
OC/CI/configuration/request/{{ID}}/{{approved}} should use alerts for alert-like information 0 2022-04-01 2023-02-05
Expose `states` from Stylable Typescript declaration file 2 2022-04-07 2023-01-07

Понравилась статья? Поделить с друзьями:
  • Error contacting the parsoid restbase server http 500
  • Error could not find a version that satisfies the requirement pygame from versions none
  • Error could not find a version that satisfies the requirement pip3 from versions none
  • Error could not find a version that satisfies the requirement pil from versions none
  • Error could not find a version that satisfies the requirement opencv python from versions none