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

bug: renaming a a component file whilst being watched causes an error #3443

Closed
3 tasks done
johnjenkins opened this issue Jun 28, 2022 · 5 comments · Fixed by #5971
Closed
3 tasks done

bug: renaming a a component file whilst being watched causes an error #3443

johnjenkins opened this issue Jun 28, 2022 · 5 comments · Fixed by #5971
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@johnjenkins
Copy link
Contributor

johnjenkins commented Jun 28, 2022

Prerequisites

Stencil Version

2~ (happens in 2.17.0 but has been present for a long time)

Current Behavior

using the latest version of stencil, whilst within --watch mode, change any component file name (e.g. my-component.tsx to my-new-component.tsx) and stencil fails with an error:

[ ERROR ]  TypeError: Cannot read property 'fileName' of undefined at flattenDiagnosticMessageText
           (.../node_modules/@stencil/core/compiler/stencil.js:1559:45) at
           loadTypeScriptDiagnostic

Expected Behavior

not to fail :)

Steps to Reproduce

npm init stencil > select the component variant.
cd NEW_COMPONENT_DIR
npm i
npm start
rename src/components/my-component.tsx to my-new-component.tsx

Code Reproduction URL

just use npm init stencil

Additional Information

No response

@ionitron-bot ionitron-bot bot added the triage label Jun 28, 2022
@rwaskiewicz rwaskiewicz self-assigned this Jun 28, 2022
@rwaskiewicz
Copy link
Member

Thanks @johnjenkins! I was able to confirm this has been around since at least v2.7.0. Labelling this so that it gets ingested into the backlog

@rwaskiewicz rwaskiewicz added Bug: Validated This PR or Issue is verified to be a bug within Stencil and removed triage labels Jun 28, 2022
@rwaskiewicz rwaskiewicz removed their assignment Jun 28, 2022
@linuxonrails
Copy link

Hi @johnjenkins!

I think it is a valid error and that it only warns you that something is wrong in the test file.

If you correct the path in src/components/my-component/my-component.spec.ts, the error disappears and the browser reloads without problems:

2c2
< import { MyComponent } from './my-component';
---
> import { MyComponent } from './my-new-component';

I think this issue could be closed or, perhaps, renamed to "Test files should be ignored in browser transpilation with npm start". But personally I prefer the build to fail if there is a test failure.

@rwaskiewicz
Copy link
Member

hey @linuxonrails,

thanks for your input! however, even when no tests exist in a project, I am able to reproduce this issue. the root cause has to do with a race condition where the dev server isn't able to understand that the file has changed it's name

alicewriteswrongs added a commit that referenced this issue Sep 21, 2022
This fixes a small issue where we were accessing a possibly-undefined
property on a TypeScript Diagnostic record.

This relates to the issue reported in #3443.
@alicewriteswrongs
Copy link
Contributor

Just a quick update on this, I just opened a small PR (#3627) which fixes a bit of diagnostic handling code where we were accessing a property on a possibly-undefined value without checking.

After fixing that issue one thing I'm consistently running into is this upstream issue in TypeScript: microsoft/TypeScript#43838

rwaskiewicz pushed a commit that referenced this issue Sep 21, 2022
#3627)

This fixes a small issue where we were accessing a possibly-undefined
property on a TypeScript Diagnostic record.

This relates to the issue reported in #3443.
tanner-reits added a commit that referenced this issue Sep 4, 2024
tanner-reits added a commit that referenced this issue Sep 5, 2024
github-merge-queue bot pushed a commit that referenced this issue Sep 6, 2024
* fix(compiler): handle file rename in watch mode

Fixes: #3443

STENCIL-1104

* fix(ci): update pipeline name

* parity w/ other test workflows

---------

Co-authored-by: Christian Bromann <[email protected]>
@christian-bromann
Copy link
Member

A fix for this has been released in Stencil v4.22.0 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
5 participants