SlideShare une entreprise Scribd logo
1  sur  57
Expect the unexpected - dealing with
errors in web apps
Mats Bryntse
Founder, @bryntum
Who is Mats Bryntse?
• From Stockholm, Sweden
• Working with Ext JS since 2007
• mankz in the Sencha forums
• Founder of Bryntum (Scheduler, Gantt, Kanban Taskboard, Siesta)
• @bryntum
What is a javascript Error?
Javascript error basics
• Javascript errors are unhandled exceptions happening in your code base
• Or in the frameworks you use
• Doesn’t matter where it happens, poor user impression regardless
• With JS codebases in the size of MBs, we can no longer ignore error handling + logging
• Good news - it’s easy ?
What does the user see when there is a JS
error?
?
Nothing, unless you show them
?
The ErrorEvent constructor
• When an error happens, an ErrorEvent is fired on the window object
• ErrorEvent.message
• ErrorEvent.filename
• ErrorEvent.lineno
• ErrorEvent.colno // Normal browsers only
• ErrorEvent.error // Normal browsers only
Global error handler
// Old school
window.onerror = function(message, source, lineno, colno, error) {
…
};
window.addEventListener(‘error’, function(event) {
// event.message
// event.filename
// event.lineno
// event.colno // good browsers only
// event.error (has stack property, in good browsers)
}, true);
…or by listening to the window ‘error’
eventListen with capture=true to also
get notified of resource load errors
Errors are easily caught in window.onerror
You can throw your own
Error too
// Bad, no call stack will be available
throw ‘My own error’;
// preferred
throw new Error(‘This will have call stack’);
try {
// Questionable code goes here
} catch(e) {
// log error
} finally {
// always called
}
• throw a String
• Or better, an Error instance
(callstack)
• Catch using simple try/catch/finally
The error reporting cycle
What’s the typical strategy for error
reporting at Enterprise X?
Flow of an error - Enterprise version
Error in web app
Reports to own support Your company
User realises it’s an error
01010
10110
11110
User Dear User,
/Depressed dev.
Can’t reproduce,
need more info.
Sincerely yours,
Too much guessing…
🕵🕵
10
points
“Add-to-cart button doesn’t
work”
9 points ‘a is undefined’
9 points ‘console.lgo is not a function’
8 points line 1, column 536171
7 points
6 points
5 points Step by step:
First login as user
Add few items to cart
Click checkout button => crash
Logging and monitoring errors in your web
app
Logging is easy
• Log message, file, line, stack etc..
• Add any extra meta relevant for your
debugging (userId/name/…)
• Poor mans error logger:
function log(msg) {
new Image().src = "log.php?msg=" +
encodeURIComponent(msg);
}
window.onerror = log;
throw new Error("Ooops");
Saving error info
• Store error logs in some database on a non-production server
• Throttle logging on client side + server side
• Probably we only care about the first error on a page
Flow of an error - Improved version
Error in web app
Your company
User realises it’s an error
01010
10110
11110
User
Making sense of a callstack is sometimes
easy…
…but often it takes a lot of detective work
🕵🕵
Solving a complex puzzle
Connecting the dots…
undefined is not a function
Bryntum - How we (used to) handle errors
Online examples is a test suite of sorts
Previous error handling at Bryntum
• Web site visitors are test monkeys unknowingly === free help
• Errors logged in a DB
• Emails sent to devs
= Very useful for finding and rapidly fixing bugs
Error handling at Bryntum
Instant feedback
Site visitors / “Late QA”Developers
Error handling at Bryntum
• What we had was pretty good, not great
• Lots of time spent playing detective, looking at callstacks
• Just error message, filename, callstack isn’t enough to rapidly locate root cause
• We would like to know more…
🕵🕵
Wish list…
Function arguments
Know how the crashing function
was called
function getUserInfo(id) {
var user = this.store.getById(id); // => null
return user.getInfo(); // Cannot call getInfo of null
}
getUserInfo(-1); // crashes, would be neat to know input args
Logs about failed ajax requests
Usually produces errors that are less tested (aka happy testing)
See how the application looked at the time of
crash
?
Know what the user did during page session
🕵
What if there was a tool that did all
this…?
🕵🕵
Introducing the new shiny…
Detailed data about users environment
Capturing arguments passed to the crashing function
Screenshot at the time of the error
Support for hiding sensitive data before
screenshot
+ environment data collected
Many things to consider…
• OS
• Browser
• Window size
• Touch support
• Window blur/focus events
• Date + Timezone
• Language
• Failed ajax requests
• Cookie state
• Network connectivity events
Timeline visualising activity
Shows ajax requests, window resizing, hide/show,
connectivity
Notifying the developers
Notifying the affected user
• Optional popup for the user that triggered the error
• Shows status of the error (New, Reproduced, Fixed)
Two way communication
Error data posted
Current error status
[new/reproduced/fixed]
Users / QADevelopers
Cuts 99% of communication out
• No need for QA to email devs about crash reports
• No need for devs to notify QA that bug is already fixed
DEMO TIME
Installing the logger in your app
var logger = new Err.ErrorLogger({
recordUserActions : true,
maxNbrLogs : 1,
logResourceLoadFailures : true,
applicationId : ‘your-cool-app‘,
version : ‘2.0.0-rc.1’,
logAjaxRequests : true,
enableScreenshot : true,
saveCookies : true,
frameworkVersion : Ext.versions.extjs.version
});
logger.addTag('ReadOnlyUser', true);
logger.addTag('Secret Flag', 'XYZ');
In a dream world we would be able to:
See on the user’s machine when error happens
live
Reproduce the error on in production
Reproduce the error locally
�
DEMO TIME
BETA release imminent
Beta testers wanted! mats@bryntum.com
Launch December 2016
Summing up:
Questions?
SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps

Contenu connexe

Tendances

Capybara-Webkit
Capybara-WebkitCapybara-Webkit
Capybara-Webkit
bostonrb
 
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirstBuilding CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Jun-ichi Sakamoto
 
Marionette structure with modules
Marionette structure with modulesMarionette structure with modules
Marionette structure with modules
matt-briggs
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
KMS Technology
 

Tendances (20)

Testing frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
 
BDD / cucumber /Capybara
BDD / cucumber /CapybaraBDD / cucumber /Capybara
BDD / cucumber /Capybara
 
Make your Backbone Application dance
Make your Backbone Application danceMake your Backbone Application dance
Make your Backbone Application dance
 
Capybara-Webkit
Capybara-WebkitCapybara-Webkit
Capybara-Webkit
 
Marionette: Building your first app
Marionette: Building your first appMarionette: Building your first app
Marionette: Building your first app
 
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram ExperienceSharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
SharePoint PowerShell for the Admin and Developer - A Venn Diagram Experience
 
Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)Crash Course in AngularJS + Ionic (Deep dive)
Crash Course in AngularJS + Ionic (Deep dive)
 
Agile documentation with Confluence and Sparx Enterprise Architect
Agile documentation with Confluence and Sparx Enterprise ArchitectAgile documentation with Confluence and Sparx Enterprise Architect
Agile documentation with Confluence and Sparx Enterprise Architect
 
Backbone/Marionette introduction
Backbone/Marionette introductionBackbone/Marionette introduction
Backbone/Marionette introduction
 
The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015The Art of AngularJS in 2015 - Angular Summit 2015
The Art of AngularJS in 2015 - Angular Summit 2015
 
Don't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and JoomlaDon't worry be API with Slim framework and Joomla
Don't worry be API with Slim framework and Joomla
 
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirstBuilding CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
Building CLR/H Registration Site with ASP.NET MVC4 and EF4CodeFirst
 
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark BrocatoSenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
SenchaCon 2016: Ext JS + React: A Match Made in UX Heaven - Mark Brocato
 
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
[Thong Nguyen & Trong Bui] Behavior Driven Development (BDD) and Automation T...
 
Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7Integrating AngularJS with Drupal 7
Integrating AngularJS with Drupal 7
 
Marionette structure with modules
Marionette structure with modulesMarionette structure with modules
Marionette structure with modules
 
Webinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST APIWebinar: AngularJS and the WordPress REST API
Webinar: AngularJS and the WordPress REST API
 
Behavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using CucumberBehavior Driven Development and Automation Testing Using Cucumber
Behavior Driven Development and Automation Testing Using Cucumber
 
PHP & MVC
PHP & MVCPHP & MVC
PHP & MVC
 
Kickstart sencha extjs
Kickstart sencha extjsKickstart sencha extjs
Kickstart sencha extjs
 

En vedette

En vedette (19)

Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and BeyondSencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
Sencha Roadshow 2017: Innovations in Ext JS 6.5 and Beyond
 
Learn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research ReportLearn Key Insights from The State of Web Application Testing Research Report
Learn Key Insights from The State of Web Application Testing Research Report
 
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App TestingSencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
Sencha Roadshow 2017: Best Practices for Implementing Continuous Web App Testing
 
SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...
SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...
SenchaCon 2016: Improve Workflow Driven Applications with Ext JS Draw Package...
 
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React AppsIntroducing ExtReact: Adding Powerful Sencha Components to React Apps
Introducing ExtReact: Adding Powerful Sencha Components to React Apps
 
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data GridLeveraging React and GraphQL to Create a Performant, Scalable Data Grid
Leveraging React and GraphQL to Create a Performant, Scalable Data Grid
 
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
Sencha Roadshow 2017: Sencha Best Practices: Coworkee App
 
Sencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop FirstSencha Roadshow 2017: Mobile First or Desktop First
Sencha Roadshow 2017: Mobile First or Desktop First
 
Building Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff StanoBuilding Ext JS Using HATEOAS - Jeff Stano
Building Ext JS Using HATEOAS - Jeff Stano
 
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
Sencha Roadshow 2017: Sencha Upgrades - The Good. The Bad. The Ugly - Eva Luc...
 
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
SenchaCon 2016: Add Magic to Your Ext JS Apps with D3 Visualizations - Vitaly...
 
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and ToolingSencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
Sencha Roadshow 2017: Modernizing the Ext JS Class System and Tooling
 
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
Sencha Roadshow 2017: BufferedStore Internals featuring eyeworkers interactiv...
 
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
SenchaCon 2016: LinkRest - Modern RESTful API Framework for Ext JS Apps - Rou...
 
Ext JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell SimeonsExt JS Architecture Best Practices - Mitchell Simeons
Ext JS Architecture Best Practices - Mitchell Simeons
 
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
Sencha Roadshow 2017: Build Progressive Web Apps with Ext JS and Cmd
 
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
SenchaCon 2016: Mobile First? Desktop First? Or Should you Think Universal Ap...
 
Sencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha TestSencha Roadshow 2017: What's New in Sencha Test
Sencha Roadshow 2017: What's New in Sencha Test
 
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark BrocatoSenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
SenchaCon 2016: Keynote Presentation - Art Landro, Gautam Agrawal, Mark Brocato
 

Similaire à SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps

Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
Mihail Mateev
 

Similaire à SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps (20)

Cross-platform logging and analytics
Cross-platform logging and analyticsCross-platform logging and analytics
Cross-platform logging and analytics
 
What Your JavaScript Does When You're Not Around (Influx Days 2017 Edition)
What Your JavaScript Does When You're Not Around (Influx Days 2017 Edition)What Your JavaScript Does When You're Not Around (Influx Days 2017 Edition)
What Your JavaScript Does When You're Not Around (Influx Days 2017 Edition)
 
Production debugging web applications
Production debugging web applicationsProduction debugging web applications
Production debugging web applications
 
Lightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error HandlingLightning Talk: JavaScript Error Handling
Lightning Talk: JavaScript Error Handling
 
Advanced Error Handling Strategies for ColdFusion
Advanced Error Handling Strategies for ColdFusion Advanced Error Handling Strategies for ColdFusion
Advanced Error Handling Strategies for ColdFusion
 
TPR4
TPR4TPR4
TPR4
 
TPR4
TPR4TPR4
TPR4
 
Do we need a bigger dev data culture
Do we need a bigger dev data cultureDo we need a bigger dev data culture
Do we need a bigger dev data culture
 
Influx/Days 2017 San Francisco | Emily Nakashima
Influx/Days 2017 San Francisco | Emily NakashimaInflux/Days 2017 San Francisco | Emily Nakashima
Influx/Days 2017 San Francisco | Emily Nakashima
 
The Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt EakinThe Art of Gherkin Scripting - Matt Eakin
The Art of Gherkin Scripting - Matt Eakin
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
orcreatehappyusers
orcreatehappyusersorcreatehappyusers
orcreatehappyusers
 
Techniques For A Modern Web UI (With Notes)
Techniques For A Modern Web UI (With Notes)Techniques For A Modern Web UI (With Notes)
Techniques For A Modern Web UI (With Notes)
 
Professional JavaScript Error-Logging
Professional JavaScript Error-LoggingProfessional JavaScript Error-Logging
Professional JavaScript Error-Logging
 
Code instrumentation
Code instrumentationCode instrumentation
Code instrumentation
 
Professional web development with libraries
Professional web development with librariesProfessional web development with libraries
Professional web development with libraries
 
Win j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateevWin j svsphonegap-damyan-petev-mihail-mateev
Win j svsphonegap-damyan-petev-mihail-mateev
 
Leveling the playing field
Leveling the playing fieldLeveling the playing field
Leveling the playing field
 
Helpful logging with python
Helpful logging with pythonHelpful logging with python
Helpful logging with python
 
Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...Max Voloshin - "Organization of frontend development for products with micros...
Max Voloshin - "Organization of frontend development for products with micros...
 

Plus de Sencha

Plus de Sencha (11)

Breathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web ComponentsBreathe New Life into Your Existing JavaScript Applications with Web Components
Breathe New Life into Your Existing JavaScript Applications with Web Components
 
Ext JS 6.6 Highlights
Ext JS 6.6 HighlightsExt JS 6.6 Highlights
Ext JS 6.6 Highlights
 
SenchaCon 2016: Developing and Delivering Quality Code, Frequently - Neil Manvar
SenchaCon 2016: Developing and Delivering Quality Code, Frequently - Neil ManvarSenchaCon 2016: Developing and Delivering Quality Code, Frequently - Neil Manvar
SenchaCon 2016: Developing and Delivering Quality Code, Frequently - Neil Manvar
 
SenchaCon 2016: Creating a Flexible and Usable Industry Specific Solution - D...
SenchaCon 2016: Creating a Flexible and Usable Industry Specific Solution - D...SenchaCon 2016: Creating a Flexible and Usable Industry Specific Solution - D...
SenchaCon 2016: Creating a Flexible and Usable Industry Specific Solution - D...
 
SenchaCon 2016: JavaScript is Great but Stop Writing It - Rory Hardy
SenchaCon 2016: JavaScript is Great but Stop Writing It - Rory HardySenchaCon 2016: JavaScript is Great but Stop Writing It - Rory Hardy
SenchaCon 2016: JavaScript is Great but Stop Writing It - Rory Hardy
 
SenchaCon 2016: Accessibility, Teamwork & Ext JS: A Customer Success Story - ...
SenchaCon 2016: Accessibility, Teamwork & Ext JS: A Customer Success Story - ...SenchaCon 2016: Accessibility, Teamwork & Ext JS: A Customer Success Story - ...
SenchaCon 2016: Accessibility, Teamwork & Ext JS: A Customer Success Story - ...
 
SenchaCon 2016: Using Ext JS 6 for Cross-Platform Development on Mobile - And...
SenchaCon 2016: Using Ext JS 6 for Cross-Platform Development on Mobile - And...SenchaCon 2016: Using Ext JS 6 for Cross-Platform Development on Mobile - And...
SenchaCon 2016: Using Ext JS 6 for Cross-Platform Development on Mobile - And...
 
SenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay Platonov
SenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay PlatonovSenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay Platonov
SenchaCon 2016: Handling Undo-Redo in Sencha Applications - Nickolay Platonov
 
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
SenchaCon 2016: How to Auto Generate a Back-end in Minutes - Per Minborg, Emi...
 
SenchaCon 2016: Turbocharge your Ext JS App - Per Minborg, Anselm McClain, Jo...
SenchaCon 2016: Turbocharge your Ext JS App - Per Minborg, Anselm McClain, Jo...SenchaCon 2016: Turbocharge your Ext JS App - Per Minborg, Anselm McClain, Jo...
SenchaCon 2016: Turbocharge your Ext JS App - Per Minborg, Anselm McClain, Jo...
 
SenchaCon 2016: Integrating Geospatial Maps & Big Data Using CartoDB via Ext ...
SenchaCon 2016: Integrating Geospatial Maps & Big Data Using CartoDB via Ext ...SenchaCon 2016: Integrating Geospatial Maps & Big Data Using CartoDB via Ext ...
SenchaCon 2016: Integrating Geospatial Maps & Big Data Using CartoDB via Ext ...
 

Dernier

Dernier (20)

Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 

SenchaCon 2016: Expect the Unexpected - Dealing with Errors in Web Apps

  • 1. Expect the unexpected - dealing with errors in web apps Mats Bryntse Founder, @bryntum
  • 2. Who is Mats Bryntse? • From Stockholm, Sweden • Working with Ext JS since 2007 • mankz in the Sencha forums • Founder of Bryntum (Scheduler, Gantt, Kanban Taskboard, Siesta) • @bryntum
  • 3. What is a javascript Error?
  • 4. Javascript error basics • Javascript errors are unhandled exceptions happening in your code base • Or in the frameworks you use • Doesn’t matter where it happens, poor user impression regardless • With JS codebases in the size of MBs, we can no longer ignore error handling + logging • Good news - it’s easy ?
  • 5. What does the user see when there is a JS error? ?
  • 6. Nothing, unless you show them ?
  • 7. The ErrorEvent constructor • When an error happens, an ErrorEvent is fired on the window object • ErrorEvent.message • ErrorEvent.filename • ErrorEvent.lineno • ErrorEvent.colno // Normal browsers only • ErrorEvent.error // Normal browsers only
  • 8. Global error handler // Old school window.onerror = function(message, source, lineno, colno, error) { … }; window.addEventListener(‘error’, function(event) { // event.message // event.filename // event.lineno // event.colno // good browsers only // event.error (has stack property, in good browsers) }, true); …or by listening to the window ‘error’ eventListen with capture=true to also get notified of resource load errors Errors are easily caught in window.onerror
  • 9. You can throw your own Error too // Bad, no call stack will be available throw ‘My own error’; // preferred throw new Error(‘This will have call stack’); try { // Questionable code goes here } catch(e) { // log error } finally { // always called } • throw a String • Or better, an Error instance (callstack) • Catch using simple try/catch/finally
  • 11. What’s the typical strategy for error reporting at Enterprise X?
  • 12. Flow of an error - Enterprise version Error in web app Reports to own support Your company User realises it’s an error 01010 10110 11110 User Dear User, /Depressed dev. Can’t reproduce, need more info. Sincerely yours,
  • 15. 9 points ‘a is undefined’
  • 16. 9 points ‘console.lgo is not a function’
  • 17. 8 points line 1, column 536171
  • 20. 5 points Step by step: First login as user Add few items to cart Click checkout button => crash
  • 21. Logging and monitoring errors in your web app
  • 22. Logging is easy • Log message, file, line, stack etc.. • Add any extra meta relevant for your debugging (userId/name/…) • Poor mans error logger: function log(msg) { new Image().src = "log.php?msg=" + encodeURIComponent(msg); } window.onerror = log; throw new Error("Ooops");
  • 23. Saving error info • Store error logs in some database on a non-production server • Throttle logging on client side + server side • Probably we only care about the first error on a page
  • 24. Flow of an error - Improved version Error in web app Your company User realises it’s an error 01010 10110 11110 User
  • 25. Making sense of a callstack is sometimes easy…
  • 26. …but often it takes a lot of detective work 🕵🕵
  • 27. Solving a complex puzzle Connecting the dots… undefined is not a function
  • 28. Bryntum - How we (used to) handle errors
  • 29. Online examples is a test suite of sorts
  • 30. Previous error handling at Bryntum • Web site visitors are test monkeys unknowingly === free help • Errors logged in a DB • Emails sent to devs = Very useful for finding and rapidly fixing bugs
  • 31. Error handling at Bryntum Instant feedback Site visitors / “Late QA”Developers
  • 32. Error handling at Bryntum • What we had was pretty good, not great • Lots of time spent playing detective, looking at callstacks • Just error message, filename, callstack isn’t enough to rapidly locate root cause • We would like to know more… 🕵🕵
  • 34. Function arguments Know how the crashing function was called function getUserInfo(id) { var user = this.store.getById(id); // => null return user.getInfo(); // Cannot call getInfo of null } getUserInfo(-1); // crashes, would be neat to know input args
  • 35. Logs about failed ajax requests Usually produces errors that are less tested (aka happy testing)
  • 36. See how the application looked at the time of crash ?
  • 37. Know what the user did during page session 🕵
  • 38. What if there was a tool that did all this…? 🕵🕵
  • 40.
  • 41. Detailed data about users environment
  • 42. Capturing arguments passed to the crashing function
  • 43. Screenshot at the time of the error
  • 44. Support for hiding sensitive data before screenshot
  • 45. + environment data collected Many things to consider… • OS • Browser • Window size • Touch support • Window blur/focus events • Date + Timezone • Language • Failed ajax requests • Cookie state • Network connectivity events
  • 46. Timeline visualising activity Shows ajax requests, window resizing, hide/show, connectivity
  • 48. Notifying the affected user • Optional popup for the user that triggered the error • Shows status of the error (New, Reproduced, Fixed)
  • 49. Two way communication Error data posted Current error status [new/reproduced/fixed] Users / QADevelopers
  • 50. Cuts 99% of communication out • No need for QA to email devs about crash reports • No need for devs to notify QA that bug is already fixed
  • 52. Installing the logger in your app var logger = new Err.ErrorLogger({ recordUserActions : true, maxNbrLogs : 1, logResourceLoadFailures : true, applicationId : ‘your-cool-app‘, version : ‘2.0.0-rc.1’, logAjaxRequests : true, enableScreenshot : true, saveCookies : true, frameworkVersion : Ext.versions.extjs.version }); logger.addTag('ReadOnlyUser', true); logger.addTag('Secret Flag', 'XYZ');
  • 53. In a dream world we would be able to: See on the user’s machine when error happens live Reproduce the error on in production Reproduce the error locally �
  • 55. BETA release imminent Beta testers wanted! mats@bryntum.com Launch December 2016 Summing up: